server: ConnectionConfig — one per-connection settings value held by Server and BoundServer - #307
Merged
Merged
Conversation
iainmcgin
force-pushed
the
rpb/b-connection-config
branch
from
September 17, 2026 04:48
572cf45 to
314acde
Compare
…y `Server` and `BoundServer` The nine per-connection fields duplicated across `Server`, `BoundServer`, their four default blocks, `serve_with_listener`'s positional parameters and `serve_accepted_stream` become one public `#[non_exhaustive]` `ConnectionConfig` (private fields, `new`, `with_*` setters, plain accessors, `Default`) in the `ClientConfig` shape. `Server` and `BoundServer` each hold one; their existing `with_*` setters forward to it and `with_connection_config` / `connection_config()` take or expose it whole, so the two builders cannot drift and a configuration crosses between them. The TLS pair is grouped the same way in a crate-private `AcceptConfig`, so the accept loop takes `(listener, service, accept, config, shutdown)` in every feature set. `Http2Config`, `RetirementConfig` and the `build_*_config` helpers are gone; max-age jitter is drawn inside the driver. Adds `ConnectionConfig::with_http2_max_header_list_size`, wired to hyper's HTTP/2 builder. Tests: the per-topic builder round-trip tests are consolidated into `ConnectionConfig` unit tests plus one test that every forward on both builders edits the field of the same name and that one value crosses between them; an h2 client sees `431` for headers over the configured list size. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BgcfmMV1ECyzhbqGvUV1a7 Signed-off-by: Ryan Brewster <rpb@anthropic.com>
`with_http2_max_header_list_size(0)` left a server that closed every connection on its first request. It now panics, like `with_max_concurrent_streams(0)`. The docs also said oversized headers get `431`, which only holds up to four times the limit: past that, h2 closes the whole connection with `GOAWAY(ENHANCE_YOUR_CALM)`. The docs, the changelog fragment and the test now cover that boundary. `Server` and `BoundServer` get the matching shorthand setter, as they have for every other connection setting. Signed-off-by: Iain McGinniss <309153+iainmcgin@users.noreply.github.com>
iainmcgin
force-pushed
the
rpb/b-connection-config
branch
from
September 18, 2026 05:41
314acde to
9db55d1
Compare
iainmcgin
marked this pull request as ready for review
September 18, 2026 05:41
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.
Implements #250 items 2–3, modelled on
ClientConfigfrom #247. Most of theserver.rsdiff moves the long setter docs fromBoundServerontoConnectionConfig;git diff --color-moved=dimmed-zebraseparates the moves from the edits.Before this, nine per-connection fields were duplicated on
ServerandBoundServer, with four hand-synchronised default blocks and a nine-argumentserve_with_listener. After, each builder holds one value, and the same value configures either:ConnectionConfig, also at the crate root (#[non_exhaustive]; derivesClone,Debug,PartialEq,Eq), holds every setting the builders apply to a connection. The builders' existingwith_*setters keep their signatures and edit that value;with_connection_config/connection_config()replace or return it whole.with_http2_max_header_list_size(u32), the advertisedSETTINGS_MAX_HEADER_LIST_SIZE(hyper's 16 KiB default is too small for some bearer tokens), with shorthands onServerandBoundServer. It panics on zero. A request whose header list reaches the limit gets431. With h2 0.4.15 and later, a connection-closing GOAWAY follows a header list past four times the limit, or a header block spread over more CONTINUATION frames than h2 allows, which can happen well under four times the limit.AcceptConfig, so the accept loop isserve_with_listener(listener, service, accept, config, shutdown)in every feature set.