Skip to content

Implement SocketsHttpHandler.InitialHttp2MaxConcurrentStreams - #132521

Merged
MihaZupan merged 6 commits into
dotnet:mainfrom
MihaZupan:http-initialh2maxstreams
Aug 20, 2026
Merged

Implement SocketsHttpHandler.InitialHttp2MaxConcurrentStreams#132521
MihaZupan merged 6 commits into
dotnet:mainfrom
MihaZupan:http-initialh2maxstreams

Conversation

@MihaZupan

Copy link
Copy Markdown
Member

Implements #132457 for .NET 12. Potential backports to 11 will follow later.

0 is technically also a valid value for this property, but I blocked it for now since it requires a bit of extra code (see bae3040), while I don't see a good realistic scenario rn. We can always add support for it back later if someone cares.

@MihaZupanMihaZupan added this to the 12.0.0 milestone Aug 19, 2026
@MihaZupanMihaZupan self-assigned this Aug 19, 2026
CopilotAI lite review requested due to automatic review settings August 19, 2026 14:21
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

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

@MihaZupan
MihaZupan requested review from a team and wfurtAugust 19, 2026 14:27

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

Adds a new SocketsHttpHandler configuration knob to cap how many HTTP/2 streams a new connection may open before the peer’s initial SETTINGS frame is observed, and adjusts the existing “last seen” SETTINGS_MAX_CONCURRENT_STREAMS behavior to respect that cap. This fits into the System.Net.Http connection-pooling and HTTP/2 stream management code paths.

Changes:

  • Introduces SocketsHttpHandler.InitialHttp2MaxConcurrentStreams (default 100, must be >= 1) and threads it through connection settings/pool initialization.
  • Updates HTTP/2 SETTINGS processing to only memorize server-advertised max-concurrent-streams values when they are lower than the configured initial cap.
  • Adds functional tests validating round-tripping, validation, and the before-SETTINGS behavior/memoization behavior.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
FileDescription
src/libraries/System.Net.Http/tests/FunctionalTests/SocketsHttpHandlerTest.csAdds API validation/roundtrip tests and HTTP/2 loopback tests covering pre-SETTINGS stream limiting and memoization rules.
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/SocketsHttpHandler.csAdds the new public property with validation and XML docs.
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/HttpConnectionSettings.csStores/clones the new initial max concurrent streams setting.
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http2Connection.csRemoves the hardcoded initial stream cap and updates SETTINGS_MAX_CONCURRENT_STREAMS handling/memoization logic.
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionPool/HttpConnectionPool.csInitializes per-pool “last seen” HTTP/2 max concurrent streams from the new setting.
src/libraries/System.Net.Http/src/System/Net/Http/HttpHandlerDefaults.csIntroduces the default constant (100) for the new property, with rationale.
src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/SocketsHttpHandler.csAdds the corresponding browser stub property throwing PNSE.
src/libraries/System.Net.Http/ref/System.Net.Http.csExposes the new public API surface in the ref assembly.

@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

@MihaZupan
MihaZupan merged commit 700f36c into dotnet:mainAug 20, 2026
86 of 88 checks passed
@MihaZupan

Copy link
Copy Markdown
MemberAuthor

/backport to release/11.0

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/11.0 (link to workflow run)

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@MihaZupan@wfurt