Issue 1595365: Urllib2 user-agent header added by an opener is "frozen" (original) (raw)

Created on 2006-11-13 02:27 by der_doener, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
header-bug.txt der_doener,2006-11-13 02:27 Sample output showing the problem
Messages (5)
msg30531 - (view) Author: Björn Steinbrink (der_doener) Date: 2006-11-13 02:27
If a Request object gets an User-agent header added by an opener, that header seems to be "frozen". Although header_items() shows the changed header, the request still uses the old one. This does not happen if the header is set before the request is passed to the opener, i.e. when the header is not set automatically, subsequent changes are respected. I'm using Python 2.4.4 from Debian's sid.
msg86315 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2009-04-22 18:49
Confirmed in trunk. Easier to copy and paste: import urllib2 h = urllib2.HTTPHandler(debuglevel = 1) opener = urllib2.build_opener(h) request = urllib2.Request('http://www.google.de/') request.header_items() opener.open(request) request.header_items() request.add_header('User-agent', 'Buggy') request.header_items() opener.open(request)
msg116182 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-09-12 12:39
What is the status of this issue?
msg117126 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2010-09-22 06:09
This is still a valid bug.
msg117435 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2010-09-27 01:41
Fixed in r85025 (py3k), r85026 (release31-maint) and r85027 (release27-maint).
History
Date User Action Args
2022-04-11 14:56:21 admin set github: 44227
2010-09-27 01:41:28 orsenthil set status: open -> closedresolution: accepted -> fixedmessages: + stage: needs patch -> resolved
2010-09-22 06:09:41 orsenthil set assignee: orsenthilresolution: acceptedmessages: + stage: test needed -> needs patch
2010-09-12 12:39:51 BreamoreBoy set nosy: + BreamoreBoytitle: User-agent header added by an opener is "frozen" -> Urllib2 user-agent header added by an opener is "frozen"messages: + versions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.6
2009-04-22 18:49:25 ajaksu2 set keywords: + patchnosy: + ajaksu2messages: +
2009-02-12 17:38:22 ajaksu2 set nosy: + orsenthilstage: test neededtype: behaviorcomponents: + Library (Lib), - Noneversions: + Python 2.6, - Python 2.4
2006-11-13 02:27:55 der_doener create