From 0bd950d67bbac3d7b1a2d0e65b9c06ba0f583698 Mon Sep 17 00:00:00 2001 From: brennobemoura <37243584+brennobemoura@users.noreply.github.com> Date: Wed, 9 Sep 2026 12:40:46 -0300 Subject: [PATCH] Only override applicationProtocols in makeTLSBootstrap when unset 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 --- .../HTTPConnectionPool+Factory.swift | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/Sources/AsyncHTTPClient/ConnectionPool/HTTPConnectionPool+Factory.swift b/Sources/AsyncHTTPClient/ConnectionPool/HTTPConnectionPool+Factory.swift index f26fc8c08..2d8a17496 100644 --- a/Sources/AsyncHTTPClient/ConnectionPool/HTTPConnectionPool+Factory.swift +++ b/Sources/AsyncHTTPClient/ConnectionPool/HTTPConnectionPool+Factory.swift @@ -574,15 +574,17 @@ extension HTTPConnectionPool.ConnectionFactory { } var tlsConfig = self.tlsConfiguration - switch self.clientConfiguration.httpVersion.configuration { - case .automatic: - // since we can support h2, we need to advertise this in alpn - // "ProtocolNameList" contains the list of protocols advertised by the - // client, in descending order of preference. - // https://datatracker.ietf.org/doc/html/rfc7301#section-3.1 - tlsConfig.applicationProtocols = ["h2", "http/1.1"] - case .http1Only: - tlsConfig.applicationProtocols = ["http/1.1"] + if tlsConfig.applicationProtocols.isEmpty { + switch self.clientConfiguration.httpVersion.configuration { + case .automatic: + // since we can support h2, we need to advertise this in alpn + // "ProtocolNameList" contains the list of protocols advertised by the + // client, in descending order of preference. + // https://datatracker.ietf.org/doc/html/rfc7301#section-3.1 + tlsConfig.applicationProtocols = ["h2", "http/1.1"] + case .http1Only: + tlsConfig.applicationProtocols = ["http/1.1"] + } } #if canImport(Network)