@@ -186,6 +186,8 @@ extension HTTPClient {
186186 public var headers : HTTPHeaders
187187 /// Request body, defaults to no body.
188188 public var body : Body ?
189+ /// Request-specific TLS configuration, defaults to no request-specific TLS configuration.
190+ public var tlsConfiguration : TLSConfiguration ?
189191
190192 struct RedirectState {
191193 var count : Int
@@ -209,11 +211,29 @@ extension HTTPClient {
209211 /// - `unsupportedScheme` if URL does contains unsupported HTTP scheme.
210212 /// - `emptyHost` if URL does not contains a host.
211213 public init ( url: String , method: HTTPMethod = . GET, headers: HTTPHeaders = HTTPHeaders ( ) , body: Body ? = nil ) throws {
214+ try self . init ( url: url, method: method, headers: headers, body: body, tlsConfiguration: nil )
215+ }
216+
217+ /// Create HTTP request.
218+ ///
219+ /// - parameters:
220+ /// - url: Remote `URL`.
221+ /// - version: HTTP version.
222+ /// - method: HTTP method.
223+ /// - headers: Custom HTTP headers.
224+ /// - body: Request body.
225+ /// - tlsConfiguration: Request TLS configuration
226+ /// - throws:
227+ /// - `invalidURL` if URL cannot be parsed.
228+ /// - `emptyScheme` if URL does not contain HTTP scheme.
229+ /// - `unsupportedScheme` if URL does contains unsupported HTTP scheme.
230+ /// - `emptyHost` if URL does not contains a host.
231+ public init ( url: String , method: HTTPMethod = . GET, headers: HTTPHeaders = HTTPHeaders ( ) , body: Body ? = nil , tlsConfiguration: TLSConfiguration ? ) throws {
212232 guard let url = URL ( string: url) else {
213233 throw HTTPClientError . invalidURL
214234 }
215235
216- try self . init ( url: url, method: method, headers: headers, body: body)
236+ try self . init ( url: url, method: method, headers: headers, body: body, tlsConfiguration : tlsConfiguration )
217237 }
218238
219239 /// Create an HTTP `Request`.
@@ -229,6 +249,23 @@ extension HTTPClient {
229249 /// - `emptyHost` if URL does not contains a host.
230250 /// - `missingSocketPath` if URL does not contains a socketPath as an encoded host.
231251 public init ( url: URL , method: HTTPMethod = . GET, headers: HTTPHeaders = HTTPHeaders ( ) , body: Body ? = nil ) throws {
252+ try self . init ( url: url, method: method, headers: headers, body: body, tlsConfiguration: nil )
253+ }
254+
255+ /// Create an HTTP `Request`.
256+ ///
257+ /// - parameters:
258+ /// - url: Remote `URL`.
259+ /// - method: HTTP method.
260+ /// - headers: Custom HTTP headers.
261+ /// - body: Request body.
262+ /// - tlsConfiguration: Request TLS configuration
263+ /// - throws:
264+ /// - `emptyScheme` if URL does not contain HTTP scheme.
265+ /// - `unsupportedScheme` if URL does contains unsupported HTTP scheme.
266+ /// - `emptyHost` if URL does not contains a host.
267+ /// - `missingSocketPath` if URL does not contains a socketPath as an encoded host.
268+ public init ( url: URL , method: HTTPMethod = . GET, headers: HTTPHeaders = HTTPHeaders ( ) , body: Body ? = nil , tlsConfiguration: TLSConfiguration ? ) throws {
232269 guard let scheme = url. scheme? . lowercased ( ) else {
233270 throw HTTPClientError . emptyScheme
234271 }
@@ -244,6 +281,7 @@ extension HTTPClient {
244281 self . scheme = scheme
245282 self . headers = headers
246283 self . body = body
284+ self . tlsConfiguration = tlsConfiguration
247285 }
248286
249287 /// Whether request will be executed using secure socket.
0 commit comments