This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: HTTPResponse.getheaders() returns lowercased header names
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Make urllib.request.Request.has_header() etc case-insensitive
View: 2275
Assigned To: Nosy List: ajaksu2, georg.brandl, tzot, yain
Priority: low Keywords:

Created on 2005-03-24 18:24 by yain, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg24774 - (view) Author: Alexey Dvoychenkov (yain) Date: 2005-03-24 18:24
I'm not sure, if this is a bug, or intentional
behaviour, because on one hand RFC states that field
names for HTTP headers are case-insensitive, on the
other hand, it's not what server really returns to client.

Example:

print response.getheaders()

Yields this (output formatted a bit for clarity):

[('content-length', '5998'), 
('accept-ranges', 'bytes'), 
('last-modified', 'Sun, 30 Jan 2005 14:36:09 GMT'), 
('connection', 'close'), 
('etag', '"26d79-176e-41fcf0d9"'), 
('date', 'Thu, 24 Mar 2005 18:14:07 GMT'), 
('content-type', 'text/html')]

msg24775 - (view) Author: Χρήστος Γεωργίου (Christos Georgiou) (tzot) * Date: 2006-03-31 16:48
Logged In: YES 
user_id=539787

I believe that since HTTP Headers are not case sensitive,
this is not a bug.
Fixing the case to either lower-case or upper-case is
typical wherever data are case insensitive, and since Python
strings are case sensitive (in this case, the header name is
being used as a key to a dict), rfc822.py selects lower-case
('suitably canonicalized') to implement case insensitivity.
msg81450 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2009-02-09 07:11
Superseder: issue 2275.
msg85552 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2009-04-05 18:44
Setting as superseder.
History
Date User Action Args
2022-04-11 14:56:10adminsetgithub: 41752
2009-04-05 18:44:39georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg85552

superseder: Make urllib.request.Request.has_header() etc case-insensitive
resolution: duplicate
2009-02-09 07:11:56ajaksu2setnosy: + ajaksu2
messages: + msg81450
2005-03-24 18:24:11yaincreate