Skip to content

Allow creating H2C connections over HTTP CONNECT proxy tunnels - #129485

Merged
MihaZupan merged 3 commits into
dotnet:mainfrom
MihaZupan:http-h2cOverProxy
Jun 30, 2026
Merged

Allow creating H2C connections over HTTP CONNECT proxy tunnels#129485
MihaZupan merged 3 commits into
dotnet:mainfrom
MihaZupan:http-h2cOverProxy

Conversation

@MihaZupan

Copy link
Copy Markdown
Member

Closes#99689

@MihaZupanMihaZupan added this to the 11.0.0 milestone Jun 16, 2026
@MihaZupanMihaZupan self-assigned this Jun 16, 2026
CopilotAI review requested due to automatic review settings June 16, 2026 22:50
@MihaZupan

Copy link
Copy Markdown
MemberAuthor

/azp run runtime-libraries-coreclr outerloop

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines successfully started running 1 pipeline(s).

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @karelz, @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

CopilotAI 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.

Pull request overview

This PR updates SocketsHttpHandler’s proxy connection pooling so that cleartext HTTP/2 (h2c) requests sent via an HTTP(S) proxy can be carried over a CONNECT tunnel (similar to existing non-secure WebSocket proxy tunneling support), enabling HTTP/2 in scenarios that previously fell back to HTTP/1.1-only proxy forwarding.

Changes:

  • Route cleartext HTTP/2 proxy requests to the ProxyTunnel connection kind (CONNECT tunneling) when HTTP/2 is required/preferred.
  • Enable HTTP/2 pooling/usage for HttpConnectionKind.ProxyTunnel.
  • Add a functional test validating when CONNECT tunneling is used vs. absolute-form forwarding through the proxy.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
FileDescription
src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.csAdds coverage for CONNECT tunneling behavior for HTTPS and cleartext HTTP/2 proxy scenarios.
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionPoolManager.csAdjusts connection key selection to use CONNECT tunneling for cleartext HTTP/2 through HTTP(S) proxies.
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionKind.csUpdates enum comments to reflect HTTP/1.1-only proxy forwarding vs. CONNECT tunneling use cases (including h2c).
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionPool/HttpConnectionPool.Http2.csAllows pooled HTTP/2 connections for ProxyTunnel pools (debug invariant update).
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionPool/HttpConnectionPool.csEnables HTTP/2 for ProxyTunnel pools by no longer force-disabling it in the constructor switch.

@MihaZupan
MihaZupan marked this pull request as ready for review June 20, 2026 15:15
CopilotAI review requested due to automatic review settings June 20, 2026 15:15

CopilotAI 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.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

@MihaZupan
MihaZupan requested a review from a teamJune 30, 2026 12:59

@wfurtwfurt left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Sign up for freeto subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HttpClient does not support cleartext HTTP/2 over http(s) proxies

3 participants

@MihaZupan@wfurt