urllib2 header casing discrepancy

D

Darren Spruell

Spent some time tripping today over HTTP headers being added to the
Request object in "proper" header case (all components title cased)
but finding that the resulting header dictionary object had the
headers keyed with first component only capitalized.

## http://paste.pound-python.org/show/3273/
'Big Poopy'

I'd expect the header put in as "User-Agent" to be stored and
retrieved using the same case but this is clearly not the case. HTTP
header names are case-insensitive so it matters not how they're sent
but programmatically it would seem like we'd want to ensure that the
specified input is preserved.

http://www.cs.tut.fi/~jkorpela/http.html
http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2

This is observed under Python 2.6.1 and 2.6.6 on OS X and Linux.

Am I misunderstanding how to use these functions? Do I need to adjust
my expectations? :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top