Skip to content

Don't treat HTTP/1 informational responses as final - #8482

Open
APX403 wants to merge 4 commits into
mitmproxy:mainfrom
APX403:http1-informational-responses
Open

APX403 wants to merge 4 commits into
mitmproxy:mainfrom
APX403:http1-informational-responses

Conversation

@APX403

@APX403 APX403 commented Oct 14, 2026

Copy link
Copy Markdown

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, Http1Client takes the 1xx for the final response. The stream ends with an empty body, the actual response is then logged as Unexpected 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 Protocols are now logged and skipped, the same way Http2Client already handles them, and the next response head is read from the buffer.

Checklist

  • I have updated tests where applicable.
  • I have added an entry to the CHANGELOG.

APX403 and others added 3 commits October 14, 2026 01:40
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 kayaal34 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@APX403

APX403 commented Oct 24, 2026

Copy link
Copy Markdown
Author

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

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AssertionError: Unexpected event: <InformationalResponseReceived

2 participants