[Patches] [ python-Patches-996159 ] correct urllib2 header capitalization (fix for #994101)

SourceForge.net noreply at sourceforge.net
Sun Jul 25 20:02:48 CEST 2004


Patches item #996159, was opened at 2004-07-22 21:48
Message generated for change (Comment added) made by jjlee
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=996159&group_id=5470

Category: Library (Lib)
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Johannes Gijsbers (jlgijsbers)
Assigned to: Nobody/Anonymous (nobody)
Summary: correct urllib2 header capitalization (fix for #994101)

Initial Comment:
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.

----------------------------------------------------------------------

Comment By: John J Lee (jjlee)
Date: 2004-07-25 19:02

Message:
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!


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=996159&group_id=5470


More information about the Patches mailing list