Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
transfer: close connection after excess data has been read #5440
For HTTP 1.x, it's a protocol error when the server sends more bytes than announced. If this happens, don't reuse the connection, because the start position of the next response is undefined.
I'm not sure whether this is also the case for other protocols, so please review carefully.
Start the test server:
Send three requests with curl:
So the second response is processed, because after reading the excess bytes, the next response line happens to be "HTTP/1.1 200 OK". The third response is not processed, because the next response line is "Content-Length: 21" - even though the size of the second response is announced correctly by the server. Whether curl processes the response depends on the position of the "sleep" command in the response script.
bagder left a comment
This seems entirely correct and I'm a little bit puzzled why we didn't do this already!
Did you look into adding a test case for this? I would be so good to make sure that we do right and have that verified with a test!