Skip to content

Commit

Permalink
fix: Bring in latest URLSessionHTTPClient from main branch (#718)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbelkins authored May 8, 2024
1 parent 8a5b010 commit 9fe617c
Show file tree
Hide file tree
Showing 8 changed files with 608 additions and 129 deletions.
29 changes: 29 additions & 0 deletions Sources/ClientRuntime/Networking/Http/CRT/TLSConfiguration.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// Copyright Amazon.com Inc. or its affiliates.
// All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//

/**
* Configuration settings about TLS set up.
* All settings are optional.
* Not specifying them will use the SDK defaults
*/
public protocol TLSConfiguration {

// Optional path to a PEM certificate
var certificate: String? { get set }

// Optional path to certificate directory
var certificateDir: String? { get set }

// Optional path to a PEM format private key
var privateKey: String? { get set }

// Optional path to PKCS #12 certificate , in PEM format
var pkcs12Path: String? { get set }

// Optional PKCS#12 password
var pkcs12Password: String? { get set }
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,22 @@
//

import struct Foundation.TimeInterval
import AwsCommonRuntimeKit

public class HttpClientConfiguration {

/// The timeout for a request, in seconds.
/// The timeout for establishing a connection, in seconds.
///
/// If none is provided, the client will use default values based on the platform.
public var connectTimeout: TimeInterval?

/// The timeout for socket, in seconds.
/// Sets maximum time to wait between two data packets.
/// Used to close stale connections that have no activity.
///
/// Defaults to 60 seconds if no value is provided.
public var socketTimeout: TimeInterval

/// HTTP headers to be submitted with every HTTP request.
///
/// If none is provided, defaults to no extra headers.
Expand All @@ -27,21 +35,33 @@ public class HttpClientConfiguration {
/// If none is provided, the default protocol for the operation will be used
public var protocolType: ProtocolType?

/// Custom TLS configuration for HTTPS connections.
///
/// Enables specifying client certificates and trust stores for secure communication.
/// Defaults to system's TLS settings if `nil`.
public var tlsConfiguration: (any TLSConfiguration)?

/// Creates a configuration object for a SDK HTTP client.
///
/// Not all configuration settings may be followed by all clients.
/// - Parameters:
/// - connectTimeout: The maximum time to wait for a response without receiving any data.
/// - connectTimeout: The maximum time to wait for a connection to be established.
/// - socketTimeout: The maximum time to wait between data packets.
/// - defaultHeaders: HTTP headers to be included with every HTTP request.
/// Note that certain headers may cause your API request to fail. Defaults to no headers.
/// - protocolType: The HTTP scheme (`http` or `https`) to be used for API requests. Defaults to the operation's standard configuration.
/// - tlsConfiguration: Optional custom TLS configuration for HTTPS requests. If `nil`, defaults to a standard configuration.
public init(
connectTimeout: TimeInterval? = nil,
socketTimeout: TimeInterval = 60.0,
protocolType: ProtocolType = .https,
defaultHeaders: Headers = Headers()
defaultHeaders: Headers = Headers(),
tlsConfiguration: (any TLSConfiguration)? = nil
) {
self.socketTimeout = socketTimeout
self.protocolType = protocolType
self.defaultHeaders = defaultHeaders
self.connectTimeout = connectTimeout
self.tlsConfiguration = tlsConfiguration
}
}
Loading

0 comments on commit 9fe617c

Please sign in to comment.