Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

urllib2 changes header names #43105

Closed
vimico mannequin opened this issue Mar 28, 2006 · 5 comments
Closed

urllib2 changes header names #43105

vimico mannequin opened this issue Mar 28, 2006 · 5 comments
Labels
stdlib Python modules in the Lib dir

Comments

@vimico
Copy link
Mannequin

vimico mannequin commented Mar 28, 2006

BPO 1459963
Nosy @birkenfeld

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2006-08-19.01:54:04.000>
created_at = <Date 2006-03-28.12:02:54.000>
labels = ['library']
title = 'urllib2 changes header names'
updated_at = <Date 2006-08-19.01:54:04.000>
user = 'https://bugs.python.org/vimico'

bugs.python.org fields:

activity = <Date 2006-08-19.01:54:04.000>
actor = 'jjlee'
assignee = 'none'
closed = True
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2006-03-28.12:02:54.000>
creator = 'vimico'
dependencies = []
files = []
hgrepos = []
issue_num = 1459963
keywords = []
message_count = 5.0
messages = ['27914', '27915', '27916', '27917', '27918']
nosy_count = 4.0
nosy_names = ['georg.brandl', 'jjlee', 'jedie', 'vimico']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue1459963'
versions = ['Python 2.4']

@vimico
Copy link
Mannequin Author

vimico mannequin commented Mar 28, 2006

It seems that urllib2 changes the writing of any
additional supplied headers, i.e. "User-Agent" becomes
"User-agent", "TEST-HEADER" becomes "Test-header".

A few sites do not recognize "User-agent" and insist on
"User-Agent".

Fix: remove all occurences of capitalize() in urllib2.

@vimico vimico mannequin closed this as completed Mar 28, 2006
@vimico vimico mannequin added the stdlib Python modules in the Lib dir label Mar 28, 2006
@jedie
Copy link
Mannequin

jedie mannequin commented Mar 28, 2006

Logged In: YES
user_id=1330780

There are old, closed Bug-Reports:
https://sourceforge.net/tracker/?group_id=5470&atid=105470&func=detail&aid=994101

?!?!?

@birkenfeld
Copy link
Member

Logged In: YES
user_id=849994

Some normalizing is important to prevent duplicate headers.
Changed capitalize() to title() to match the default casing
(now user-agent becomes User-Agent) in rev. 43399.

@vimico
Copy link
Mannequin Author

vimico mannequin commented Mar 28, 2006

Logged In: YES
user_id=928834

I checked the database before submitting... I admit, I
haven't gone back 2 years. :-)

It seems to be the same bug. But it was still present in
2.4.2 (version used in Ubuntu Breezy).

@jjlee
Copy link
Mannequin

jjlee mannequin commented Aug 19, 2006

Logged In: YES
user_id=261020

Patch 1459963 (applied in 50842) should be reverted and a
better patch applied (see below), since this one needlessly
breaks the old (albeit undocumented) interface of direct
access to request.headers (which existed prior to the
introduction of the .get_header() &c. methods).

Patch 1542948 reverts 50842's changes to urllib2 (it does
not revert the changes to urllib) and fixes the reported
issue with a one-line fix in AbstractHTTPHandler
(.title()-case the HTTP headers before sending them to
httplib). That fix is also more localised to HTTP -- urllib2
knows about other protocols too. This patch also corrects a
mis-wording in Misc/NEWS: the old case convention was not
strictly incorrect (according to RFC 2616), but just did not
follow the usual title-case convention.

If the original patch was applied to the 2.4 maintenance
branch, I guess patch 1542948 should be applied there too.

(Just BTW: With hindsight, the methods should never have
been introduced (which was done when the "unredirected"
headers were introduced), but rather request.headers changed
to be a class != dict: that was my fault, and it's too late
to fix that...)

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

1 participant