Repository navigation
Conversation
Http1Client took a 1xx response such as 103 Early Hints for the final response: the stream ended with an empty body and the real response was then logged as unexpected data from the server, so the client never got it. Skip informational responses other than 101 Switching Protocols, as Http2Client already does, and keep reading the next response head. Fixes mitmproxy#5050.
kayaal34
left a comment
There was a problem hiding this comment.
Ran test/mitmproxy/proxy/layers/http/ on this branch: 226 passed.
I also tried a case the new tests don't cover: two informational responses before the final one, all in one read (102 Processing, then 103 Early Hints with a link header, then 200 OK with a 2-byte body). Both 1xx are logged and swallowed and the 200 is delivered with its body, so the new while loop handles consecutive 1xx responses. It could be worth adding that as a third case to test_informational_response, since the loop is what makes it work.
(I used an AI assistant to help go through the change; I ran the tests myself.)
The existing cases only have one informational response. Here 102 Processing and 103 Early Hints come in the same read as the 200, so the loop has to continue past the first one.
|
Thanks for trying that. I added it as a third case of test_informational_response, with 102 and 103 in the same read as the 200 |
Description
Fixes #5050. The HTTP/2 crash reported there was already fixed by #5332, so what remains is the HTTP/1 case from #2229, which was closed as a duplicate of #5050.
When an HTTP/1 server sends an informational response before the final one, for example
103 Early Hints,Http1Clienttakes the 1xx for the final response. The stream ends with an empty body, the actual response is then logged asUnexpected data from server, and the client waits until it times out. This happens in regular and reverse proxy mode.Informational responses other than
101 Switching Protocolsare now logged and skipped, the same wayHttp2Clientalready handles them, and the next response head is read from the buffer.Checklist