[New-bugs-announce] [issue2756] urllib2 add_header fails with existing unredirected_header
report at bugs.python.org
Sun May 4 17:11:38 CEST 2008
New submission from david reid <mail at david-reid.com>:
In urllib2 when using reusing a Request calling add_header doesn't work
when an unredirected_header has been added.
A good example (and the one that caught me out) is content-type. When
making a POST request with no content-type set the current code sets the
content-type as an unredirected_header to
'application/x-www-form-urlencoded' (line 1034 of urllib2.py) but in a
subsequent request, setting the content type via add_header will see
this ignored as unredirected_headers are appended after the headers.
A possible solution is to check whether the header being added already
exists in the requests undredirected_headers and remove it if it does.
components: Library (Lib)
title: urllib2 add_header fails with existing unredirected_header
versions: Python 2.5
Tracker <report at bugs.python.org>
More information about the New-bugs-announce