[issue12455] urllib2 Request() forces capitalize() on header names, breaking some requests
Cal Leeming
report at bugs.python.org
Thu Jun 30 21:39:53 CEST 2011
Cal Leeming <cal.leeming at simplicitymedialtd.co.uk> added the comment:
Sorry, I should clarify.. The str() patch worked, but it failed to work within the realm of urllib2:
s = _str("Content-MD5")
print "Builtin:"
print "plain: %s" % ( s )
print "capitalized: %s" % ( s.capitalize() )
s = str("Content-MD5")
print "Builtin:"
print "plain: %s" % ( s )
print "capitalized: %s" % ( s.capitalize() )
Builtin:
plain: Content-MD5
capitalized: Content-MD5
Builtin:
plain: Content-MD5
capitalized: Content-md5
Why it works in the unit test, and not within urllib2, is totally beyond me. Especially since I put a debug call on the method, and it does get called.. yet urllib2 debug still shows it sending the wrong value.
---
capitalize() bypassed: sending value: Content-MD5
send: 'POST /api/url\r\nContent-Md5: nts0yj7AdzJALyNOxafDyA==\r\n\r\n'
---
I have a feeling that the problem may lie somewhere after the opener (like HTTPConnection or AbstractHTTPHandler), rather than the urllib2 calls to capitalize(), but not having much luck monkey patching those :X
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12455>
_______________________________________
More information about the Python-bugs-list
mailing list