Bug 863070 - httplib produces headers in wrong encoding
Summary: httplib produces headers in wrong encoding
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: python
Version: 5.8
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Dave Malcolm
QA Contact: BaseOS QE - Apps
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-10-04 11:42 UTC by Martin Kudlej
Modified: 2013-03-21 05:06 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2013-03-21 05:06:51 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Martin Kudlej 2012-10-04 11:42:20 UTC
Description of problem:
I've got 2 scripts with almost the same code. Both use M2Crypto to wrap communication of python suds library and use HTTPConnection from httplib.py. Both scripts are SOAP clients for server based on Apache AXIS. First one script is script written in iso-latin1 and everything works ok. Second one is not fully written in iso-latin1 and it doesn't work. I've found that problem is in httplib.py where it creates HTTP headers as python unicode string which are not correct HTTP headers because they should be encoded only in latin1. Then AXIS library on server side cannot parse headers.
I don't know why once python create those headers in latin1 encoding and other time it creates headers in unicode. I've tried to change shell locales where I run that non-functional script, it has no effect. I've tried change encoding of source codes like here http://www.python.org/dev/peps/pep-0263/ , it has no effect. So only one working solution, which I've found, is to modify function HTTPConnection._send_output from httplib.py which is used just for sending headers.

Proposal patch:
   def _send_output(self):
     self._buffer.extend(("", ""))
-    msg = str("\r\n".join(self._buffer))
+    msg = "\r\n".join(self._buffer)
     del self._buffer[:]
     self.send(msg)

Version-Release number of selected component (if applicable):
$ cat /etc/issue
Red Hat Enterprise Linux Server release 5.8 (Tikanga)
Kernel \r on an \m

I see this bug also on RHEL6, should I open the same bug also for RHEL6?

$ rpm -qa | grep python | sort
audit-libs-python-1.8-2.el5
dbus-python-0.70-9.el5_4
gamin-python-0.1.7-10.el5
gnome-python2-2.16.0-1.fc6
gnome-python2-bonobo-2.16.0-1.fc6
gnome-python2-gconf-2.16.0-1.fc6
gnome-python2-gnomevfs-2.16.0-1.fc6
ipython-0.8.4-1.el5
libselinux-python-1.33.4-5.7.el5
libvirt-python-0.8.2-25.el5
libxml2-python-2.7.3-4.el5
libxslt-python-1.1.24-6.el5
python-2.4.3-46.el5_8.2
python-condorutils-1.5-4.el5
python-devel-2.4.3-46.el5_8.2
python-dmidecode-3.10.13-1.el5_5.1
python-elementtree-1.2.6-5
python-ethtool-0.6-5.el5
python-hashlib-20081119-4.el5
python-iniparse-0.2.3-4.el5
python-kerberos-1.1-4.1.el5
python-krbV-1.0.90-1.el5
python-ldap-2.2.0-2.1
python-libs-2.4.3-46.el5_8.2
python-linux-procfs-0.4.5-1.el5rt
python-lxml-2.0.11-1.el5
python-numeric-23.7-2.2.2.el5_6.1
python-pip-0.8-1.el5
python-psycopg2-2.0.14-3.el5
python-pycurl-7.15.5.1-8.el5
python-qpid-0.14-11.el5
python-qpid-qmf-0.14-14.el5
python-saslwrapper-0.10-4.el5
python-schedutils-0.2-2.el5rt
python-setuptools-0.6.10-3.el5
python-simplejson-2.0.9-8.el5
python-sqlite-1.1.7-1.2.1
python-ssl-1.15-3.el5
python-suds-0.4.1-2.el5
python-urlgrabber-3.1.0-6.el5
python-wallabyclient-4.1.3-1.el5
rhts-devel-python-3.3-54.el5
rhts-python-4.51-1.el5
rpm-python-4.4.2.3-28.el5_8

How reproducible:
100%

Actual results:
It produces http headers in unicode.

Expected results:
It will produce https headers always in latin1.

Comment 2 RHEL Program Management 2013-03-21 05:06:51 UTC
Development Management has reviewed and declined this request.
You may appeal this decision by reopening this request.


Note You need to log in before you can comment on or make changes to this bug.