Skip to content

Commit 7e5a523

Browse files
committed
make HTTPVersion public and set to .automatic by default
1 parent 170fd53 commit 7e5a523

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

Diff for: Sources/AsyncHTTPClient/HTTPClient.swift

+7-12
Original file line numberDiff line numberDiff line change
@@ -603,10 +603,8 @@ public class HTTPClient {
603603
/// Ignore TLS unclean shutdown error, defaults to `false`.
604604
public var ignoreUncleanSSLShutdown: Bool
605605

606-
// TODO: make public
607-
// TODO: set to automatic by default
608-
/// HTTP/2 is by default disabled
609-
internal var httpVersion: HTTPVersion
606+
/// is set to `.automatic` by default which will use HTTP/2 if run over https and the server supports it, otherwise HTTP/1
607+
public var httpVersion: HTTPVersion
610608

611609
public init(
612610
tlsConfiguration: TLSConfiguration? = nil,
@@ -624,13 +622,11 @@ public class HTTPClient {
624622
proxy: proxy,
625623
ignoreUncleanSSLShutdown: ignoreUncleanSSLShutdown,
626624
decompression: decompression,
627-
// TODO: set to automatic by default
628-
httpVersion: .http1Only
625+
httpVersion: .automatic
629626
)
630627
}
631628

632-
// TODO: make public
633-
internal init(
629+
public init(
634630
tlsConfiguration: TLSConfiguration? = nil,
635631
redirectConfiguration: RedirectConfiguration? = nil,
636632
timeout: Timeout = Timeout(),
@@ -862,18 +858,17 @@ extension HTTPClient.Configuration {
862858
}
863859
}
864860

865-
// TODO: make this struct and its static properties public
866-
internal struct HTTPVersion {
861+
public struct HTTPVersion {
867862
internal enum Configuration {
868863
case http1Only
869864
case automatic
870865
}
871866

872867
/// we only use HTTP/1, even if the server would supports HTTP/2
873-
internal static let http1Only: Self = .init(configuration: .http1Only)
868+
public static let http1Only: Self = .init(configuration: .http1Only)
874869

875870
/// HTTP/2 is used if we connect to a server with HTTPS and the server supports HTTP/2, otherwise we use HTTP/1
876-
internal static let automatic: Self = .init(configuration: .automatic)
871+
public static let automatic: Self = .init(configuration: .automatic)
877872

878873
internal var configuration: Configuration
879874
}

Diff for: Tests/AsyncHTTPClientTests/HTTP2ClientTests.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15-
// TODO: remove @testable once we officially support HTTP/2
16-
@testable import AsyncHTTPClient // Tests that really need @testable go into HTTP2ClientInternalTests.swift
15+
/* NOT @testable */ import AsyncHTTPClient // Tests that really need @testable go into HTTP2ClientInternalTests.swift
1716
#if canImport(Network)
1817
import Network
1918
#endif

0 commit comments

Comments
 (0)