Demian Brecht added the comment:

Sorry Martin, I should really not dig into issues like this first thing in the 
morning ;)

My concern about the proposed change isn't whether or not it isn't valid HTTP 
behaviour, it is. My concern (albeit a small one) is that the change implies an 
assumption that may not necessarily be true. No matter how valid based on the 
HTTP spec, it's still an assumption that /can/ potentially lead to confusion. I 
do agree that a change /should/ be made, I just want to make sure that all 
potential cases are considered before implementing one.

For example, applying the following patch to the first attachment:

52,57c52,53
<         self.wfile.write(
<             b"HTTP/1.1 200 Dropping connection\r\n"
<             b"Content-Length: 0\r\n"
<             b"\r\n"
<         )
<
---
>         self.wfile.write(b'')
>

Should the proposed change be made, the above would error out with a 
ConnectionClosed exception, which is invalid because the connection has not 
actually been closed and BadStatusLine is actually closer to being correct. 
Admittedly, this is a little contrived, doesn't adhere to the HTTP spec and is 
much less likely to happen in the real world than a connection unexpectedly 
closed by the server, but I don't think it's an unreasonable assumption for 
lesser used servers or proxies or those in development. In those cases, the 
proposed change would result in just as much confusion as the current behaviour 
with connections that are intended to be persistent.

In my mind, the one constant through both of these cases is that the response 
that the client has read is unexpected. In light of that, rather than a 
ConnectionClosed error, what about UnexpectedResponse, inheriting from 
BadStatusLine for backwards compatibility and documented as possibly being 
raised as a result of either case? I think this would cover both cases where a 
socket has been closed as well as an altogether invalid 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

Reply via email to