[issue22478] tests for urllib2net are in bad shapes
karl
report at bugs.python.org
Wed Sep 24 10:33:53 CEST 2014
karl added the comment:
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'}
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22478>
_______________________________________
More information about the Python-bugs-list
mailing list