Skip to content

Update default HTTP/2 settings#85

Merged
FranzBusch merged 1 commit into
swift-server:mainfrom
aryan-25:update-default-http2-settings
May 27, 2026
Merged

Update default HTTP/2 settings#85
FranzBusch merged 1 commit into
swift-server:mainfrom
aryan-25:update-default-http2-settings

Conversation

@aryan-25
Copy link
Copy Markdown
Collaborator

Motivation:

As part of passing the HTTP/2 configuration values to NIOHTTP2Handler, we override NIOHTTP2Handler's ConnectionConfiguration's initialSettings.

This means we do not use the sensible defaults provided for ConnectionConfiguration's initialSettings by the nioDefaultSettings property, which sets maxConcurrentStreams to 100, and maxHeaderListSize to 1 << 14.

Modifications:

  • Updated the value of the internal defaultMaxConcurrentStreams property and the public maxConcurrentStreams property in NIOHTTPServerConfiguration.HTTP2 from nil (translates to no limit on the max concurrent streams) to 100.

    • The types of these properties were also updated from Int? to Int, which also required the initializer to be updated. Users can no longer express unlimited maxConcurrentStreams and must either provide a concrete limit or implicitly use the default value of 100.
    • Updated the swift-configuration integration to reflect this change.
  • Added the values contained in nioDefaultSettings to the initial settings array that we override.

  • Raised the swift-nio-http2 dependency version to 1.44.0 in order to use the NIOHPACK product, which provides the default value for maxHeaderListSize.

Result:

We now set sensible default HTTP/2 settings.

Motivation:

As part of passing the HTTP/2 configuration values to `NIOHTTP2Handler`, we [override](https://github.com/swift-server/swift-http-server/blob/32abef29361e9add364e50e1fc85ac761f7d0651/Sources/NIOHTTPServer/NIOHTTPServer.swift#L349) [`NIOHTTP2Handler`'s `ConnectionConfiguration`'s `initialSettings`](https://github.com/apple/swift-nio-http2/blob/61d1b44f6e4e118792be1cff88ee2bc0267c6f9a/Sources/NIOHTTP2/HTTP2ChannelHandler.swift#L1512).

This means we do not use the sensible defaults provided for `ConnectionConfiguration`'s `initialSettings` by the [`nioDefaultSettings` property](https://github.com/apple/swift-nio-http2/blob/61d1b44f6e4e118792be1cff88ee2bc0267c6f9a/Sources/NIOHTTP2/HTTP2ChannelHandler.swift#L20), which sets `maxConcurrentStreams` to 100, and
`maxHeaderListSize` to `1 << 14`.

Modifications:

- Updated the value of the `internal` `defaultMaxConcurrentStreams` property and the public `maxConcurrentStreams` property in `NIOHTTPServerConfiguration.HTTP2`  from `nil` (translates to no limit on the max concurrent streams) to `100`.
  - The types of these properties were also updated from `Int?` to `Int`, which also required the initializer to be updated. Users can no longer express unlimited `maxConcurrentStreams` and must either provide a concrete limit or implicitly use the default value of `100`.
  - Updated the `swift-configuration` integration to reflect this change.

- Added the values contained in `nioDefaultSettings` to the initial settings array that we override.

- Raised the `swift-nio-http2` dependency version to `1.44.0` in order to use the `NIOHPACK` product, which provides the default value for `maxHeaderListSize`.

Result:

We now set sensible default HTTP/2 settings.
@aryan-25 aryan-25 added the ⚠️ semver/major Breaks existing public API. label May 27, 2026
@aryan-25 aryan-25 requested a review from gjcairo May 27, 2026 10:26
@FranzBusch FranzBusch merged commit f2a3c93 into swift-server:main May 27, 2026
18 of 24 checks passed
@aryan-25 aryan-25 deleted the update-default-http2-settings branch May 27, 2026 16:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⚠️ semver/major Breaks existing public API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants