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 mgdelmonte
Recipients mgdelmonte
Date 2015-06-02.15:06:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Initially reported at

Closely related to

An HTTP response with an invalid header line that contains non-blank characters but *no* colon (contrast in which it contained a colon as the first character) causes the same behavior.

httplib.HTTPMessage.readheaders() oddly does not appear even to attempt to follow RFC 2616, which requires the header to terminate with a blank line.  The invalid header line, which admittedly also breaks RFC 2616, is at least non-blank and should not terminate the header.  Yet readheaders() takes it as an indicator that the header is over and then fails properly to process the rest of the response.

The problem is exacerbated by a chunked encoding, which will not be properly received if the encoding header is not seen because readheaders() terminates early.  An example (why are banks always the miscreants here?) is:

p = response.get("")

My recommended fix would be to insert these lines at httplib:327

                # continue reading headers on non-blank lines
                elif not len(line.strip()):
                # break only on blank lines

This would cause readheaders() to terminate only on a non-blank non-header non-comment line, in accordance with RFC 2616.
Date User Action Args
2015-06-02 15:06:03mgdelmontesetrecipients: + mgdelmonte
2015-06-02 15:06:03mgdelmontesetmessageid: <>
2015-06-02 15:06:03mgdelmontelinkissue24363 messages
2015-06-02 15:06:03mgdelmontecreate