[Python-bugs-list] [ python-Bugs-831271 ]
httplib.HTTPConnection._send_request header parsing bug
SourceForge.net
noreply at sourceforge.net
Mon Oct 27 14:57:35 EST 2003
Bugs item #831271, was opened at 2003-10-27 12:57
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=831271&group_id=5470
Category: Extension Modules
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Jason R. Coombs (jaraco)
Assigned to: Nobody/Anonymous (nobody)
Summary: httplib.HTTPConnection._send_request header parsing bug
Initial Comment:
The test on lines 730-731 of httplib.py as released with
Python 2.3.2 doesn't do what it's intended to do.
Consider
>>> headers = { 'hoST': 'www.someplace.org' }
>>> 'Host' in ( headers or [k for k in headers.iterkeys() if
k.lower() == 'host' ] )
False
This sample code demonstrates that the code in httplib
at line 730 doesn't work as intended (it should return
true for any dict who's keys include 'host' of any case).
Clearly the 'or' syntax has confused someone here,
because the portion after the or (if executed) is always
an empty list. I recommend instead
if 'host' in map( str.lower, headers.keys() ):
Or a better general solution might be to force all header
keys to be case-insensitive strings by overriding str and
dict to new case-insensitive versions, something like the
attached. This idea, however, is just a suggestion, and
probably needs to be thought through more thoroughly.
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=831271&group_id=5470
More information about the Python-bugs-list
mailing list