Skip to content

Commit 961833b

Browse files
committed
make HTTPVersion public and set to .automatic by default
1 parent 38bbe25 commit 961833b

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

Sources/AsyncHTTPClient/HTTPClient.swift

+7-12
Original file line numberDiff line numberDiff line change
@@ -607,10 +607,8 @@ public class HTTPClient {
607607
set {}
608608
}
609609

610-
// TODO: make public
611-
// TODO: set to automatic by default
612-
/// HTTP/2 is by default disabled
613-
internal var httpVersion: HTTPVersion
610+
/// is set to `.automatic` by default which will use HTTP/2 if run over https and the server supports it, otherwise HTTP/1
611+
public var httpVersion: HTTPVersion
614612

615613
public init(
616614
tlsConfiguration: TLSConfiguration? = nil,
@@ -628,13 +626,11 @@ public class HTTPClient {
628626
proxy: proxy,
629627
ignoreUncleanSSLShutdown: ignoreUncleanSSLShutdown,
630628
decompression: decompression,
631-
// TODO: set to automatic by default
632-
httpVersion: .http1Only
629+
httpVersion: .automatic
633630
)
634631
}
635632

636-
// TODO: make public
637-
internal init(
633+
public init(
638634
tlsConfiguration: TLSConfiguration? = nil,
639635
redirectConfiguration: RedirectConfiguration? = nil,
640636
timeout: Timeout = Timeout(),
@@ -865,18 +861,17 @@ extension HTTPClient.Configuration {
865861
}
866862
}
867863

868-
// TODO: make this struct and its static properties public
869-
internal struct HTTPVersion {
864+
public struct HTTPVersion {
870865
internal enum Configuration {
871866
case http1Only
872867
case automatic
873868
}
874869

875870
/// we only use HTTP/1, even if the server would supports HTTP/2
876-
internal static let http1Only: Self = .init(configuration: .http1Only)
871+
public static let http1Only: Self = .init(configuration: .http1Only)
877872

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

881876
internal var configuration: Configuration
882877
}

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)