Fix CONNECT response framing and IPv6 authority in tunnel proxies#493
Merged
Conversation
RFC 9110 (section 9.3.6) forbids these header fields in a successful
response to CONNECT and requires clients to ignore them when present.
The HTTP/1 parser treated them as regular body framing, so a proxy
replying to CONNECT with "200" plus "content-length: 0" - which some
real proxies send - emitted {:done, ref} as a body response, and
Mint.TunnelProxy rejected the tunnel with :unexpected_trailing_responses.
Any 2xx response to CONNECT is now body-less: the response is done at
the end of the header section and everything after it belongs to the
tunnel, so it stays in the buffer instead of being parsed.
The authority-form request target requires IPv6 addresses to be enclosed in square brackets (RFC 3986, section 3.2.2), but the tunnel proxy sent "CONNECT ::1:443" for IPv6 targets, which proxies cannot parse unambiguously.
Coverage Report for CI Build 0Coverage increased (+0.3%) to 87.881%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
whatyouhide
approved these changes
Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two fixes to HTTP/1
CONNECTtunnel establishment:Content-LengthandTransfer-Encodingheader fields in a 2xx response to CONNECT. The HTTP/1 parser treated them as regular body framing, so a proxy replying with200pluscontent-length: 0— which some real proxies send — emitted{:done, ref}as a body response andMint.TunnelProxyrejected the tunnel with:unexpected_trailing_responses. Any 2xx response to CONNECT is now body-less: the response ends at the header section, and everything after it belongs to the tunnel, so it stays in the buffer instead of being parsed as HTTP.CONNECT ::1:443for IPv6 targets, which proxies cannot parse unambiguously.Both are covered by parser-level tests and by a new offline test module that runs full tunnel establishment against a local CONNECT proxy, so they run in the default suite without Docker.