Author martin.panter
Recipients Yuri.Bochkarev, agriffis, alanjds, amak, cananian, demian.brecht, gregory.p.smith, icordasc, jcea, jhylton, martin.panter, mhammond, orsenthil, r.david.murray, rbcollins
Date 2015-01-20.02:28:29
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1421720910.13.0.833623470762.issue3566@psf.upfronthosting.co.za>
In-reply-to
Content
Calling self.wfile.write(b"") should be equivalent to not calling write() at all, as far as I understand. Using strace, it does not seem to invoke send() at all. So the result will depend on what is written next. In the case of my code, nothing is written next; the connection is shut down instead. So I don’t believe this case is any different from “a connection unexpectedly closed by the server”. To be clear, I think the situation we are talking about is:

1. Client connects to server and sends short request; server accepts connection and possibly reads request
2. Server does not write any response, or just calls write(b""), which is equivalent
3. Server shuts down connection
4. Client reads end of stream (b"") instead of proper status line

But to address your concern in any case, see the third paragram in <https://bugs.python.org/issue3566#msg234330>. I propose some internal flag like HTTPConnection._initial_response, that gets set to False after the first proper response is received. Then the code could be changed to something like:

if not line:
    # Presumably, the server closed the connection before
    # sending a valid response.
    if self._initial_response:
        raise BadStatusLine(line)
    else:
        raise ConnectionClosed("Stream ended before receiving response")
History
Date User Action Args
2015-01-20 02:28:30martin.pantersetrecipients: + martin.panter, jhylton, mhammond, gregory.p.smith, jcea, orsenthil, amak, rbcollins, cananian, r.david.murray, alanjds, agriffis, icordasc, demian.brecht, Yuri.Bochkarev
2015-01-20 02:28:30martin.pantersetmessageid: <1421720910.13.0.833623470762.issue3566@psf.upfronthosting.co.za>
2015-01-20 02:28:30martin.panterlinkissue3566 messages
2015-01-20 02:28:29martin.pantercreate