Red Hat Bugzilla – Bug 863070
httplib produces headers in wrong encoding
Last modified: 2013-03-21 01:06:51 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.
- msg = str("\r\n".join(self._buffer))
+ msg = "\r\n".join(self._buffer)
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
It produces http headers in unicode.
It will produce https headers always in latin1.
Development Management has reviewed and declined this request.
You may appeal this decision by reopening this request.