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: correct urllib2 header capitalization (fix for #994101)
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: jjlee, jlgijsbers
Priority: normal Keywords: patch

Created on 2004-07-22 20:48 by jlgijsbers, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
urllib2-capitalization.diff jlgijsbers, 2004-07-22 20:48 urllib2 capitalization corrections
Messages (3)
msg46435 - (view) Author: Johannes Gijsbers (jlgijsbers) * (Python triager) Date: 2004-07-22 20:48
urllib2.py version 1.72 uses capitalize() on HTTP
header names. This results in headers like "User-agent"
instead of "User-Agent". The former form is used
throughout the module as well. This is incorrect.

In this patch I've removed the capitalize() calls and
used the correct form throughout both the module.and
the tests.
msg46436 - (view) Author: John J Lee (jjlee) Date: 2004-07-25 18:02
Logged In: YES 
user_id=261020

The form "User-agent" is not incorrect, merely unconventional 
(see RFC 2616, section 4.2).

The .capitalize() calls were introduced to make headers 
properly case-insensitive while keeping old code working -- 
see patch 649742.

The problem has arisen because urllib2 recently switched to 
using httplib.HTTPConnection (and the .request() method in 
particular, which sends Content-Length automatically) where 
previously it used httplib.HTTP (which did not send Content-
Length automatically).

The real problem is that httplib.HTTPConnection.request() 
sends some headers without checking that they aren't 
already in the explicitly requested headers.  I have submitted 
patch 997626 to fix this.

Thanks for reporting this, Johannes!
msg46437 - (view) Author: Johannes Gijsbers (jlgijsbers) * (Python triager) Date: 2004-07-27 11:23
Logged In: YES 
user_id=469548

Thanks for the explanation, self-rejecting this one.
History
Date User Action Args
2022-04-11 14:56:05adminsetgithub: 40626
2004-07-22 20:48:23jlgijsberscreate