[issue12849] Cannot override 'connection: close' in urllib2 headers

Martin Panter report at bugs.python.org
Mon Feb 17 03:32:28 CET 2014


Martin Panter added the comment:

I suggest using setdefault() in urllib.request.AbstractHTTPHandler.do_open():

    headers.setdefault("Connection", "close")

I am trying to work around a server that truncates its response when this header is sent, and this change would allow me to specify headers={"Connection", "Keep-Alive"} to get the same effect as dropping the Connection header. This is also consistent with the way the other headers (Accept-Encoding, User-Agent, Host) may be overridden.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12849>
_______________________________________


More information about the Python-bugs-list mailing list