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.

Title: http.client: missing response headers when malformed header is part of the response
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.5
Status: closed Resolution: duplicate
Dependencies: Superseder: httplib fails to handle semivalid HTTP headers
View: 24363
Assigned To: Nosy List: gboudreau, r.david.murray
Priority: normal Keywords:

Created on 2017-02-04 20:29 by gboudreau, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (3)
msg286987 - (view) Author: Guillaume Boudreau (gboudreau) Date: 2017-02-04 20:29
Tested using urllib3 1.20

>>> import urllib3
>>> http = urllib3.PoolManager()
>>> r = http.request('GET', '')
>>> r.status
>>> r.headers
HTTPHeaderDict({'Date': 'Sat, 04 Feb 2017 20:09:21 GMT'})

I'm pretty sure the problem is caused by an invalid HTTP header returned by the server:

    HTTP/1.1 200 OK
    Date: Sat, 04 Feb 2017 19:16:34 GMT
    My Param: None

It directly follows the Date response header, which is returned fine, but since no other response headers is returned, I think this broken header is breaking the HTTP response headers parser.

Of note: the `http.client.HTTPresponse.headers` object (`HTTPMessage`) shows all headers in `_payload`, but only the `Date` header in `_headers`.
Thus why I think this is a http.client issue, and not a urllib3 issue.
msg286990 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-02-04 20:58
This appears to be a duplicate of issue 24363.  Does the patch there fix the problem for you?
msg287023 - (view) Author: Guillaume Boudreau (gboudreau) Date: 2017-02-05 00:10
Yes, indeed. The latest patch in 24363 resolves this issue.
Sorry for the duplicate.
Date User Action Args
2022-04-11 14:58:42adminsetgithub: 73631
2017-02-05 00:10:37gboudreausetmessages: + msg287023
2017-02-04 20:58:55r.david.murraysetstatus: open -> closed

superseder: httplib fails to handle semivalid HTTP headers

nosy: + r.david.murray
messages: + msg286990
resolution: duplicate
stage: resolved
2017-02-04 20:29:53gboudreaucreate