Skip to content

Respect a caller-provided applicationProtocols in makeTLSBootstrap - #930

Closed
o-nnerb wants to merge 2 commits into
swift-server:mainfrom
request-dl:claude/applicationprotocols-override-fix-0e8cc0
Closed

o-nnerb wants to merge 2 commits into
swift-server:mainfrom
request-dl:claude/applicationprotocols-override-fix-0e8cc0

Conversation

@o-nnerb

@o-nnerb o-nnerb commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

makeTLSBootstrap always overwrites tlsConfig.applicationProtocols based on the configured httpVersion, even when the caller already set their own ALPN protocol list on the TLSConfiguration they passed in via HTTPClientConfiguration.tlsConfiguration. That list was silently discarded.

This only sets applicationProtocols from httpVersion when the caller left it empty, so a custom ALPN list set on the TLSConfiguration itself is respected.

o-nnerb and others added 2 commits September 9, 2026 12:40
Previously the ALPN protocol list was unconditionally overwritten based
on the configured HTTP version, discarding any applicationProtocols the
caller had already set on their own TLSConfiguration.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@fabianfett

Copy link
Copy Markdown
Member

Would you mind describing your use-case here?

@o-nnerb

o-nnerb commented Oct 14, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for asking, and sorry for the noise. I took another look from the RequestDL side, which is where this came from. RequestDL exposed applicationProtocols(_:) as a pass-through to TLSConfiguration, and that value was being discarded by AHC. That is what led me to open this PR.

I now think the right API for this is the existing HTTPClient.Configuration.httpVersion, not a custom ALPN list on the TLSConfiguration. AHC owns ALPN negotiation (matchALPNToHTTPVersion only accepts h2 and http/1.1), so respecting an arbitrary list would only let the two settings contradict each other. I've fixed this on the RequestDL side, so I'm closing this PR.

I'm leaving a note for anyone who hits the same surprise (a value set on TLSConfiguration.applicationProtocols having no effect): to control the protocol, use httpVersion:

  • .http1Only forces HTTP/1.1
  • .automatic (the default) uses HTTP/2 when the server supports it over HTTPS, and HTTP/1.1 otherwise

There's currently no way to force HTTP/2-only, and AHC doesn't support HTTP/3.

@o-nnerb o-nnerb closed this Oct 14, 2026
o-nnerb added a commit to request-dl/async-http-client that referenced this pull request Oct 14, 2026
…nset" (#23)

This reverts commit 0bd950d. RequestDL now controls the protocol through
HTTPClient.Configuration.httpVersion, so the fork no longer needs to diverge
from upstream here (swift-server#930 was closed).

Co-authored-by: brennobemoura <37243584+brennobemoura@users.noreply.github.com>
Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
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.

2 participants