Skip to content

Commit 9fe617c

Browse files
authored
fix: Bring in latest URLSessionHTTPClient from main branch (#718)
1 parent 8a5b010 commit 9fe617c

File tree

8 files changed

+608
-129
lines changed

8 files changed

+608
-129
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
//
2+
// Copyright Amazon.com Inc. or its affiliates.
3+
// All Rights Reserved.
4+
//
5+
// SPDX-License-Identifier: Apache-2.0
6+
//
7+
8+
/**
9+
* Configuration settings about TLS set up.
10+
* All settings are optional.
11+
* Not specifying them will use the SDK defaults
12+
*/
13+
public protocol TLSConfiguration {
14+
15+
// Optional path to a PEM certificate
16+
var certificate: String? { get set }
17+
18+
// Optional path to certificate directory
19+
var certificateDir: String? { get set }
20+
21+
// Optional path to a PEM format private key
22+
var privateKey: String? { get set }
23+
24+
// Optional path to PKCS #12 certificate , in PEM format
25+
var pkcs12Path: String? { get set }
26+
27+
// Optional PKCS#12 password
28+
var pkcs12Password: String? { get set }
29+
}

Sources/ClientRuntime/Networking/Http/HttpClientConfiguration.swift

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,22 @@
66
//
77

88
import struct Foundation.TimeInterval
9+
import AwsCommonRuntimeKit
910

1011
public class HttpClientConfiguration {
1112

12-
/// The timeout for a request, in seconds.
13+
/// The timeout for establishing a connection, in seconds.
1314
///
1415
/// If none is provided, the client will use default values based on the platform.
1516
public var connectTimeout: TimeInterval?
1617

18+
/// The timeout for socket, in seconds.
19+
/// Sets maximum time to wait between two data packets.
20+
/// Used to close stale connections that have no activity.
21+
///
22+
/// Defaults to 60 seconds if no value is provided.
23+
public var socketTimeout: TimeInterval
24+
1725
/// HTTP headers to be submitted with every HTTP request.
1826
///
1927
/// If none is provided, defaults to no extra headers.
@@ -27,21 +35,33 @@ public class HttpClientConfiguration {
2735
/// If none is provided, the default protocol for the operation will be used
2836
public var protocolType: ProtocolType?
2937

38+
/// Custom TLS configuration for HTTPS connections.
39+
///
40+
/// Enables specifying client certificates and trust stores for secure communication.
41+
/// Defaults to system's TLS settings if `nil`.
42+
public var tlsConfiguration: (any TLSConfiguration)?
43+
3044
/// Creates a configuration object for a SDK HTTP client.
3145
///
3246
/// Not all configuration settings may be followed by all clients.
3347
/// - Parameters:
34-
/// - connectTimeout: The maximum time to wait for a response without receiving any data.
48+
/// - connectTimeout: The maximum time to wait for a connection to be established.
49+
/// - socketTimeout: The maximum time to wait between data packets.
3550
/// - defaultHeaders: HTTP headers to be included with every HTTP request.
3651
/// Note that certain headers may cause your API request to fail. Defaults to no headers.
3752
/// - protocolType: The HTTP scheme (`http` or `https`) to be used for API requests. Defaults to the operation's standard configuration.
53+
/// - tlsConfiguration: Optional custom TLS configuration for HTTPS requests. If `nil`, defaults to a standard configuration.
3854
public init(
3955
connectTimeout: TimeInterval? = nil,
56+
socketTimeout: TimeInterval = 60.0,
4057
protocolType: ProtocolType = .https,
41-
defaultHeaders: Headers = Headers()
58+
defaultHeaders: Headers = Headers(),
59+
tlsConfiguration: (any TLSConfiguration)? = nil
4260
) {
61+
self.socketTimeout = socketTimeout
4362
self.protocolType = protocolType
4463
self.defaultHeaders = defaultHeaders
4564
self.connectTimeout = connectTimeout
65+
self.tlsConfiguration = tlsConfiguration
4666
}
4767
}

0 commit comments

Comments
 (0)