Skip to content

Keep HTTP/1.0 CONNECT tunnel sockets open - #503

Merged
ericmj merged 1 commit into
elixir-mint:mainfrom
nallwhy:fix/http10-connect-tunnel
Sep 6, 2026
Merged

ericmj merged 1 commit into
elixir-mint:mainfrom
nallwhy:fix/http10-connect-tunnel

Conversation

@nallwhy

@nallwhy nallwhy commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix HTTPS tunnel establishment through proxies that return a successful HTTP/1.0 response to CONNECT, such as Tinyproxy.

A successful CONNECT response switches the underlying connection into tunnel mode. However, after the CONNECT response framing changes in #493, Mint finalized the response using the normal HTTP/1.0 persistence rules.

Because HTTP/1.0 connections are non-persistent by default, this closed the underlying TCP socket before Mint attempted the TLS upgrade. On OTP 29, upgrading the closed socket resulted in:

%Mint.TransportError{reason: {:dtls_upgrade, :notsup}}

Changes

  • Keep the underlying socket open after any successful CONNECT response.

  • Do not apply the response HTTP version or Connection header persistence rules once a tunnel has been established.

  • Add a unit test verifying that an HTTP/1.0 200 response to CONNECT leaves the socket open.

  • Add an end-to-end regression test using a Tinyproxy-style response:

    HTTP/1.0 200 Connection established
    Proxy-agent: tinyproxy/1.11.1

@whatyouhide
whatyouhide requested a review from ericmj September 5, 2026 14:17
@ericmj
ericmj merged commit 2ed27ca into elixir-mint:main Sep 6, 2026
3 checks passed
@ericmj

ericmj commented Sep 6, 2026

Copy link
Copy Markdown
Member

Thank you! 馃挏

wahve3 added a commit to Tymeslot/tymeslot that referenced this pull request Sep 14, 2026
Since 1.15.3, every https:// request made through an HTTP proxy stalled
for 30 seconds and then failed with a tunnel timeout, taking CalDAV
sync, calendar availability and the video provider integrations with it.

The proxy tuple's fourth element holds the options for the socket opened
to the proxy, and mint picks its proxying strategy from the *target's*
scheme. An http:// target goes through Mint.UnsafeProxy, which hands
that socket straight to Finch, so it has to be passive. An https://
target goes through Mint.TunnelProxy, which speaks CONNECT over it first
by waiting on socket messages, so it has to stay in mint's default
active mode. 1.15.3 set mode: :passive for both, so the CONNECT reply
was never delivered and the handshake blocked until tunnel_timeout.

The option is now chosen from the target URL's scheme, which the caller
already has. A stalled CONNECT is bounded by the same 10s budget as the
connect itself rather than by mint's 30s default.

ProxySocketOptionsTest drives real sockets through a stub proxy on
loopback: the tests this got past asserted the option list the code
produced, so they moved with it.

One case stays broken: a proxy that answers CONNECT with an HTTP/1.0
status line and no keep-alive (tinyproxy does). mint 1.10.0 applies
HTTP/1.0 persistence rules to that reply and closes the socket before
the TLS upgrade, which then fails with {:dtls_upgrade, :notsup}. That is
fixed upstream in elixir-mint/mint#503 but not yet released; picking it
up is a dependency bump, not a change here.

Refs #97

Signed-off-by: Luka Breitig <24662784+wahve3@users.noreply.github.com>
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.

2 participants