Author demian.brecht
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.01:55:42
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1421718943.42.0.237006645322.issue3566@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2015-01-20 01:55:43demian.brechtsetrecipients: + demian.brecht, jhylton, mhammond, gregory.p.smith, jcea, orsenthil, amak, rbcollins, cananian, r.david.murray, alanjds, agriffis, martin.panter, icordasc, Yuri.Bochkarev
2015-01-20 01:55:43demian.brechtsetmessageid: <1421718943.42.0.237006645322.issue3566@psf.upfronthosting.co.za>
2015-01-20 01:55:43demian.brechtlinkissue3566 messages
2015-01-20 01:55:42demian.brechtcreate