Bug 863070 - httplib produces headers in wrong encoding
httplib produces headers in wrong encoding
Status: CLOSED WONTFIX
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: python (Show other bugs)
5.8
Unspecified Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Dave Malcolm
BaseOS QE - Apps
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-10-04 07:42 EDT by Martin Kudlej
Modified: 2013-03-21 01:06 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-03-21 01:06:51 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Martin Kudlej 2012-10-04 07:42:20 EDT
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 Product and Program Management 2013-03-21 01:06:51 EDT
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.