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.

Author karlcow
Recipients karlcow
Date 2014-09-24.08:33:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1411547633.83.0.465406904057.issue22478@psf.upfronthosting.co.za>
In-reply-to
Content
Ah! the User-Agent (or anything which is in unredirected_hdrs) will not be updated if it has already been set once. 
https://hg.python.org/cpython/file/064f6baeb6bd/Lib/urllib/request.py#l1154


>>> headers = dict(request.unredirected_hdrs)
>>> headers
{'User-agent': 'Python-urllib/3.4', 'Host': '127.0.0.1'}
>>> request.headers
{'User-agent': 'Test-Agent', 'Foo': 'cool'}
>>> headers.update(dict((k, v) for k, v in request.headers.items() if k not in headers))
>>> headers
{'User-agent': 'Python-urllib/3.4', 'Host': '127.0.0.1', 'Foo': 'cool'}
History
Date User Action Args
2014-09-24 08:33:53karlcowsetrecipients: + karlcow
2014-09-24 08:33:53karlcowsetmessageid: <1411547633.83.0.465406904057.issue22478@psf.upfronthosting.co.za>
2014-09-24 08:33:53karlcowlinkissue22478 messages
2014-09-24 08:33:53karlcowcreate