[issue2275] urllib2 header capitalization

Martin McNickle report at bugs.python.org
Tue May 6 14:21:46 CEST 2008


Martin McNickle <mmcnickle at gmail.com> added the comment:

This looks good.  I would suggest that the unredirected_hdrs would use
the CaseInsensitiveDict too.

There is still the problem (from the test documentation) that accessing
.headers directly will only show a subset of headers i.e. it won't show
any headers from .unredirected_hdrs.  Have you any suggestions as to how
they both can be accessed from the same interface?

The test documentation also says:

"Note the case normalization of header names here, to
.capitalize()-case.  This should be preserved for
backwards-compatibility.  (In the HTTP case, normalization to
.title()-case is done by urllib2 before sending headers to
httplib)."

It suggests that capitalize() should be kept for backwards
compatibility.  I have tested and the headers actually sent to the
server are in title()-case even though they are stored in the Request
object as captitalize()-case.

This would initially suggest that the case-normalization should be
removed from the patch.  However, as .headers would now be using a
case-insensitive dictionary, this would still ensure backwards compatibily.

----------
nosy: +BitTorment

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2275>
__________________________________


More information about the Python-bugs-list mailing list