Skip to content

✨ Allow configuring ClientSettings on ConnectionManager - #2619

Open
banglcb wants to merge 2 commits into
cfug:mainfrom
banglcb:feat/2606
Open

banglcb wants to merge 2 commits into
cfug:mainfrom
banglcb:feat/2606

Conversation

@banglcb

@banglcb banglcb commented Oct 9, 2026 •

Copy link
Copy Markdown

Closes #2606.

ConnectionManager gains an optional clientSettings, passed to ClientTransportConnection.viaSocket for every connection it creates. null (the default) keeps package:http2's defaults, so existing behavior is unchanged. ClientSettings is re-exported from dio_http2_adapter so callers need no direct http2 dependency.

Why one ClientSettings rather than streamWindowSize/concurrentStreamLimit ints as sketched in #2606: the stream window alone does not lift the cap. In package:http2 up to 3.1.0 the connection receive window is fixed at 65535 bytes, so at most 64 KiB is in flight per round trip whatever streamWindowSize is. dart-lang/http#1999 (merged, in http2 3.2.0-wip, not yet on pub.dev) adds Settings.connectionWindowSize and Settings.maxFrameSize. Taking the whole ClientSettings lets users of http2 3.2 set those without another dio API change, and works today with ^2.1.0 (streamWindowSize, concurrentStreamLimit, allowServerPushes). No dependency constraint changes.

For reference, with http2 3.2's settings (streamWindowSize 6 MiB, connectionWindowSize 16 MiB, maxFrameSize 1 MiB), a 4 MiB body from a Go net/http server through 100 ms of added RTT took ~340 ms against ~350 ms for HTTP/1.1, and 7.1 s with the defaults (numbers from dart-lang/http#1997).

Verification: two tests in test/http2_test.dart read the client's first SETTINGS frame off the wire through a local h2c server: with clientSettings it carries SETTINGS_INITIAL_WINDOW_SIZE = 1 MiB (fails when the settings are not passed to viaSocket), without it the setting is absent as before. dart analyze --fatal-infos and dart format are clean for the package; dart test in plugins/http2_adapter passes 104 tests.

Unverified: three existing ALPN tests that drive openssl s_server fail on my Windows machine, identically on unmodified main (fails with HandshakeException when only h2 is advertised..., routes to fallbackAdapter when h2 and http/1.1 are both advertised..., ...through a proxy); I rely on CI for those. I did not run melos run test across the other packages, which this change does not touch.

AI disclosure: implementation, tests and this description were drafted with Claude (Claude Code) and reviewed by me.

New Pull Request Checklist

  • I have read the Documentation (not applicable — only the http2_adapter package docs and source were relevant)
  • I have read the Agent Contribution Guidelines (required if any part of the change was produced with AI assistance)
  • I have searched for a similar pull request in the project and found none
  • I have updated this branch with the latest main branch to avoid conflicts (via merge from master or rebase)
  • I have added the required tests to prove the fix/feature I'm adding
  • I have updated the documentation (if necessary)
  • I have run the tests without failures (three pre-existing openssl-based ALPN tests fail locally on unmodified main too; see Unverified)
  • I have updated the CHANGELOG.md in the corresponding package

`ConnectionManager` gains an optional `clientSettings`, passed to
`ClientTransportConnection.viaSocket` for every connection. `null` keeps
`package:http2`'s defaults, so existing behavior is unchanged.
`ClientSettings` is exported so callers need no direct `http2` dependency.

Closes cfug#2606
@banglcb
banglcb requested a review from a team as a code owner October 9, 2026 00:47
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.

[http2_adapter] Flow-control window is not configurable, causing 21x slower large-body downloads over HTTP/2 vs HTTP/1.1

1 participant