@@ -7,18 +7,14 @@ extension HTTPClient.Configuration {
77 ///
88 /// ## Configuration keys:
99 /// - `dnsOverrides` (string array, optional): Colon-separated host:IP pairs for DNS overrides (e.g., "localhost:127.0.0.1").
10- /// - `redirect.mode` (string, optional, default: "follow"): Redirect handling mode ("follow" or "disallow").
11- /// - `redirect.maxRedirects` (int, optional, default: 5): Maximum allowed redirects (used when mode is "follow").
12- /// - `redirect.allowCycles` (bool, optional, default: false): Allow cyclic redirects (used when mode is "follow").
13- /// - `timeout.connectionMs` (int, optional): Connection timeout in milliseconds.
14- /// - `timeout.readMs` (int, optional): Read timeout in milliseconds.
15- /// - `timeout.writeMs` (int, optional): Write timeout in milliseconds.
16- /// - `connectionPool.idleTimeoutMs` (int, optional, default: 60000): Connection idle timeout in milliseconds.
17- /// - `connectionPool.concurrentHTTP1ConnectionsPerHostSoftLimit` (int, optional, default: 8): Soft limit for concurrent HTTP/1.1 connections per host.
18- /// - `connectionPool.retryConnectionEstablishment` (bool, optional, default: true): Retry failed connection establishment.
19- /// - `connectionPool.preWarmedHTTP1ConnectionCount` (int, optional, default: 0): Number of pre-warmed HTTP/1.1 connections per host.
20- /// - `httpVersion` (string, optional): HTTP version to use ( "automatic" or "http1Only").
21- /// - `maximumUsesPerConnection` (int, optional): Maximum uses per connection.
10+ /// - `redirect` (scoped): Redirect handling configuration read by ``RedirectConfiguration/init(configReader:)``.
11+ /// - `timeout` (scoped): Timeout configuration read by ``Timeout/init(configReader:)``.
12+ /// - `connectionPool` (scoped): Connection pool configuration read by ``ConnectionPool/init(configReader:)``.
13+ /// - `httpVersion` (string, optional, default: automatic): HTTP version to use ( "automatic" or "http1Only").
14+ /// - `maximumUsesPerConnection` (int, optional, default: nil, no limit): Maximum uses per connection.
15+ ///
16+ /// - Throws: `HTTPClientError.invalidRedirectConfiguration` if redirect mode is invalid.
17+ /// - Throws: `HTTPClientError.invalidHTTPVersionConfiguration` if httpVersion is specified but invalid.
2218 public init ( configReader: ConfigReader ) throws {
2319 self . init ( )
2420
@@ -46,7 +42,15 @@ extension HTTPClient.Configuration {
4642
4743@available ( macOS 15 . 0 , iOS 18 . 0 , watchOS 11 . 0 , tvOS 18 . 0 , visionOS 2 . 0 , * )
4844extension HTTPClient . Configuration . RedirectConfiguration {
49- fileprivate init ( configReader: ConfigReader ) throws {
45+ /// Initializes redirect configuration from a ConfigReader.
46+ ///
47+ /// ## Configuration keys:
48+ /// - `mode` (string, optional, default: "follow"): Redirect handling mode ("follow" or "disallow").
49+ /// - `maxRedirects` (int, optional, default: 5): Maximum allowed redirects when mode is "follow".
50+ /// - `allowCycles` (bool, optional, default: false): Allow cyclic redirects when mode is "follow".
51+ ///
52+ /// - Throws: `HTTPClientError.invalidRedirectConfiguration` if mode is specified but invalid.
53+ public init ( configReader: ConfigReader ) throws {
5054 guard let mode = configReader. string ( forKey: " mode " ) else {
5155 // default
5256 self = . follow( max: 5 , allowCycles: false )
@@ -66,7 +70,13 @@ extension HTTPClient.Configuration.RedirectConfiguration {
6670
6771@available ( macOS 15 . 0 , iOS 18 . 0 , watchOS 11 . 0 , tvOS 18 . 0 , visionOS 2 . 0 , * )
6872extension HTTPClient . Configuration . Timeout {
69- fileprivate init ( configReader: ConfigReader ) {
73+ /// Initializes timeout configuration from a ConfigReader.
74+ ///
75+ /// ## Configuration keys:
76+ /// - `connectionMs` (int, optional, default: 10,000): Connection timeout in milliseconds.
77+ /// - `readMs` (int, optional): Read timeout in milliseconds.
78+ /// - `writeMs` (int, optional): Write timeout in milliseconds.
79+ public init ( configReader: ConfigReader ) {
7080 self . init ( )
7181 self . connect = configReader. int ( forKey: " connectionMs " ) . map { TimeAmount . milliseconds ( Int64 ( $0) ) }
7282 self . read = configReader. int ( forKey: " readMs " ) . map { TimeAmount . milliseconds ( Int64 ( $0) ) }
@@ -76,7 +86,14 @@ extension HTTPClient.Configuration.Timeout {
7686
7787@available ( macOS 15 . 0 , iOS 18 . 0 , watchOS 11 . 0 , tvOS 18 . 0 , visionOS 2 . 0 , * )
7888extension HTTPClient . Configuration . ConnectionPool {
79- fileprivate init ( configReader: ConfigReader ) {
89+ /// Initializes connection pool configuration from a ConfigReader.
90+ ///
91+ /// ## Configuration keys:
92+ /// - `idleTimeoutMs` (int, optional, default: 60,000): Connection idle timeout in milliseconds.
93+ /// - `concurrentHTTP1ConnectionsPerHostSoftLimit` (int, optional, default: 8): Soft limit for concurrent HTTP/1.1 connections per host.
94+ /// - `retryConnectionEstablishment` (bool, optional, default: true): Retry failed connection establishment.
95+ /// - `preWarmedHTTP1ConnectionCount` (int, optional, default: 0): Number of pre-warmed HTTP/1.1 connections per host.
96+ public init ( configReader: ConfigReader ) {
8097 self . init ( )
8198 self . idleTimeout = TimeAmount . milliseconds ( Int64 ( configReader. int ( forKey: " idleTimeoutMs " , default: 60000 ) ) )
8299 self . concurrentHTTP1ConnectionsPerHostSoftLimit = configReader. int (
0 commit comments