Issue 994101: urllib2: improper capitalization of headers (original) (raw)

This issue has been migrated to GitHub: https://github.com/python/cpython/issues/40600

classification

Title: urllib2: improper capitalization of headers
Type: Stage:
Components: Library (Lib) Versions: Python 2.4

process

Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: franklinmint, georg.brandl, jedie, jjlee, jlgijsbers
Priority: normal Keywords:

Created on 2004-07-19 21:22 by franklinmint, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (7)
msg21695 - (view) Author: Robert Sayre (franklinmint) Date: 2004-07-19 21:22
urllib2.py version 1.72 uses capitalize() on HTTP header names. This results in headers like "User-agent" instead of "User-Agent". This causes HTTP 400 errors on some servers when the request has a body, because there are two content length headers placed in the request: "Content-Length" (inserted by httplib) "Content-length" (inserted by Request.add_unredirected_header) The capitalization is incorrect, and httplib inserts Content-Length anyway, so I'm not sure why urllib2 is bothering.
msg21696 - (view) Author: Johannes Gijsbers (jlgijsbers) * (Python triager) Date: 2004-07-22 20:48
Logged In: YES user_id=469548 Patch is available at http://python.org/sf/996159.
msg21697 - (view) Author: John J Lee (jjlee) Date: 2004-07-25 18:06
Logged In: YES user_id=261020 I've added a comment to 996159 which explains what's wrong and points to a new patch.
msg21698 - (view) Author: Johannes Gijsbers (jlgijsbers) * (Python triager) Date: 2005-01-09 14:56
Logged In: YES user_id=469548 This was fixed by the new patch jjlee provided (#997626).
msg21699 - (view) Author: Jens Diemer (jedie) Date: 2006-03-28 12:18
Logged In: YES user_id=1330780 This isn't fixed: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1459963&group_id=5470
msg21700 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-03-28 12:23
Logged In: YES user_id=849994 It is. This bug report was about duplicate headers in the request, while the one you mention is about the capitalization per se.
msg21701 - (view) Author: Jens Diemer (jedie) Date: 2006-03-28 12:24
Logged In: YES user_id=1330780 Ah, OK... Sorry ;)
History
Date User Action Args
2022-04-11 14:56:05 admin set github: 40600
2004-07-19 21:22:58 franklinmint create