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: httplib: false BadStatusLine() raised
Type: behavior Stage: resolved
Components: Documentation, Library (Lib) Versions: Python 2.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: orsenthil Nosy List: Shoham Peller, demian.brecht, djc, jwilk, karlcow, martin.panter, miss-islington, mschu, orsenthil
Priority: normal Keywords:

Created on 2010-04-18 22:45 by mschu, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 1453 closed python-dev, 2017-05-04 13:21
PR 1654 closed python-dev, 2017-05-18 19:09
PR 2825 merged shohamp, 2017-07-23 14:48
Messages (9)
msg103545 - (view) Author: (mschu) Date: 2010-04-18 22:45
Independent from HTTP strict, an invalid BadStatusLine() exception is raised when a keep-alive connection exceeds its timeout:

client->server <request>
s->c <answer>
<connection timeout passing>
s->c: FIN/ACK
c->s: ACK
c->s: <get request>/FIN
s->c: RST (without data)

which raises the exception.

An easy workaround is to either poll information often enough for the server to not close the connection or close and reopen the connection. However, the exception is misleading.
msg183575 - (view) Author: karl (karlcow) * Date: 2013-03-06 02:44
Hmm no code.
I wonder if it's about this part.
msg231410 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2014-11-20 03:30
See also Issue 3566, which also brings up the false BadStatusLine exception, and suggests some kind of retry logic.

Whatever exception it is, it could be documented better. In Issue 66621, the poster thought it should be an IncompleteRead exception.
msg231411 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2014-11-20 03:33
Sorry the IncompleteRead reference was meant to be Issue 666219
msg234105 - (view) Author: Demian Brecht (demian.brecht) * (Python triager) Date: 2015-01-16 01:03
This should likely be closed as a duplicate of #3566, which has additional detail.
msg246926 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015-07-19 00:11
Issue 3566 has added a new exception subclass, RemoteDisconnected, in 3.5. People are still complaining about the old BadStatusLine exception in Python 2 though. See Issue 23054.

Python 2 could still get better documentation of the BadStatusLine exception. Currently it gives the impression that it only happens when the “strict” parameter is True, and a status line was received that was not understood.

The exception message could also be improved. Due to Issue 7427, there is a special case to make the message literally two quote signs (''), representing an empty string. Perhaps messages like “End of stream signalled”, “No status line”, or “Empty status line” would be clearer.
msg289498 - (view) Author: Shoham Peller (Shoham Peller) Date: 2017-03-12 12:11
How about back-porting the v3.5 fix, and the new "RemoteDisconnected" exception? Is that reasonable?
msg289513 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2017-03-12 21:56
I don’t think so. It is best to avoid a new exception type (even a subclass) in a bug fix. That would break code which checks “type(exc) == BadStatusLine” or similar.

Specific exception messages are supposed to be implementation details, and the current message is already quirky due to the change from Issue 7427 (released in 2.7a4). That is why I thought it might be reasonable to just change the exception message in a bug fix.
msg325414 - (view) Author: miss-islington (miss-islington) Date: 2018-09-14 23:28
New changeset ee78ba2c819b0cd7671a575e584d8fe1b7adb3e4 by Miss Islington (bot) (Shoham Peller) in branch '2.7':
[2.7] closes bpo-8450: a better error message when http status line isn't received (GH-2825)
Date User Action Args
2022-04-11 14:57:00adminsetgithub: 52697
2018-09-14 23:28:10miss-islingtonsetstatus: open -> closed

nosy: + miss-islington
messages: + msg325414

resolution: fixed
stage: needs patch -> resolved
2017-07-23 14:48:58shohampsetpull_requests: + pull_request2877
2017-05-18 19:09:16python-devsetpull_requests: + pull_request1748
2017-05-04 13:21:40python-devsetpull_requests: + pull_request1551
2017-03-12 21:56:02martin.pantersetmessages: + msg289513
2017-03-12 12:11:05Shoham Pellersetnosy: + Shoham Peller
messages: + msg289498
2016-05-14 08:38:29martin.pantersetstage: needs patch
versions: - Python 2.6, Python 3.1, Python 3.2
2015-07-19 00:36:57martin.pantersetcomponents: + Documentation
2015-07-19 00:36:27martin.panterlinkissue23054 superseder
2015-07-19 00:11:44martin.pantersetmessages: + msg246926
2015-01-16 01:03:14demian.brechtsetmessages: + msg234105
2015-01-14 23:48:36jwilksetnosy: + jwilk
2015-01-12 17:55:16demian.brechtsetnosy: + demian.brecht
2014-11-20 03:33:33martin.pantersetmessages: + msg231411
2014-11-20 03:30:20martin.pantersetnosy: + martin.panter
messages: + msg231410
2013-03-06 02:44:24karlcowsetnosy: + karlcow
messages: + msg183575
2011-03-18 02:09:35orsenthilsetassignee: orsenthil
nosy: orsenthil, djc, mschu
2010-08-03 14:17:27djcsetnosy: + djc
2010-04-19 12:24:16pitrousetpriority: normal
nosy: + orsenthil

versions: + Python 3.1, Python 2.7, Python 3.2
2010-04-18 22:45:28mschucreate