mirror of
https://github.com/swift-server/async-http-client.git
synced 2026-06-02 07:37:34 +00:00
[HTTP2] Make HTTPVersion public and set to .automatic by default (#473)
This commit is contained in:
@@ -607,10 +607,8 @@ public class HTTPClient {
|
||||
set {}
|
||||
}
|
||||
|
||||
// TODO: make public
|
||||
// TODO: set to automatic by default
|
||||
/// HTTP/2 is by default disabled
|
||||
internal var httpVersion: HTTPVersion
|
||||
/// is set to `.automatic` by default which will use HTTP/2 if run over https and the server supports it, otherwise HTTP/1
|
||||
public var httpVersion: HTTPVersion
|
||||
|
||||
public init(
|
||||
tlsConfiguration: TLSConfiguration? = nil,
|
||||
@@ -620,29 +618,6 @@ public class HTTPClient {
|
||||
proxy: Proxy? = nil,
|
||||
ignoreUncleanSSLShutdown: Bool = false,
|
||||
decompression: Decompression = .disabled
|
||||
) {
|
||||
self.init(
|
||||
tlsConfiguration: tlsConfiguration,
|
||||
redirectConfiguration: redirectConfiguration,
|
||||
timeout: timeout, connectionPool: connectionPool,
|
||||
proxy: proxy,
|
||||
ignoreUncleanSSLShutdown: ignoreUncleanSSLShutdown,
|
||||
decompression: decompression,
|
||||
// TODO: set to automatic by default
|
||||
httpVersion: .http1Only
|
||||
)
|
||||
}
|
||||
|
||||
// TODO: make public
|
||||
internal init(
|
||||
tlsConfiguration: TLSConfiguration? = nil,
|
||||
redirectConfiguration: RedirectConfiguration? = nil,
|
||||
timeout: Timeout = Timeout(),
|
||||
connectionPool: ConnectionPool = ConnectionPool(),
|
||||
proxy: Proxy? = nil,
|
||||
ignoreUncleanSSLShutdown: Bool = false,
|
||||
decompression: Decompression = .disabled,
|
||||
httpVersion: HTTPVersion
|
||||
) {
|
||||
self.tlsConfiguration = tlsConfiguration
|
||||
self.redirectConfiguration = redirectConfiguration ?? RedirectConfiguration()
|
||||
@@ -650,7 +625,7 @@ public class HTTPClient {
|
||||
self.connectionPool = connectionPool
|
||||
self.proxy = proxy
|
||||
self.decompression = decompression
|
||||
self.httpVersion = httpVersion
|
||||
self.httpVersion = .automatic
|
||||
}
|
||||
|
||||
public init(tlsConfiguration: TLSConfiguration? = nil,
|
||||
@@ -865,18 +840,17 @@ extension HTTPClient.Configuration {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: make this struct and its static properties public
|
||||
internal struct HTTPVersion {
|
||||
public struct HTTPVersion {
|
||||
internal enum Configuration {
|
||||
case http1Only
|
||||
case automatic
|
||||
}
|
||||
|
||||
/// we only use HTTP/1, even if the server would supports HTTP/2
|
||||
internal static let http1Only: Self = .init(configuration: .http1Only)
|
||||
public static let http1Only: Self = .init(configuration: .http1Only)
|
||||
|
||||
/// HTTP/2 is used if we connect to a server with HTTPS and the server supports HTTP/2, otherwise we use HTTP/1
|
||||
internal static let automatic: Self = .init(configuration: .automatic)
|
||||
public static let automatic: Self = .init(configuration: .automatic)
|
||||
|
||||
internal var configuration: Configuration
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user