Martin Panter added the comment: 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") ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue3566> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com