From ccc11f9164b7f1086c6381fa48d5416fedb6ec18 Mon Sep 17 00:00:00 2001 From: Patrick Wolowicz Date: Tue, 25 Mar 2025 13:52:09 +0100 Subject: [PATCH 01/15] Making choice of implementation public --- Sources/OpenAPIURLSession/URLSessionTransport.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/OpenAPIURLSession/URLSessionTransport.swift b/Sources/OpenAPIURLSession/URLSessionTransport.swift index 13a6cd3..56deb8b 100644 --- a/Sources/OpenAPIURLSession/URLSessionTransport.swift +++ b/Sources/OpenAPIURLSession/URLSessionTransport.swift @@ -71,14 +71,14 @@ public struct URLSessionTransport: ClientTransport { /// If none is provided, the system uses the shared URLSession. public init(session: URLSession = .shared) { self.init(session: session, implementation: .platformDefault) } - enum Implementation { + public enum Implementation: Sendable { case buffering case streaming(requestBodyStreamBufferSize: Int, responseBodyStreamWatermarks: (low: Int, high: Int)) } - var implementation: Implementation + public var implementation: Implementation - init(session: URLSession = .shared, implementation: Implementation = .platformDefault) { + public init(session: URLSession = .shared, implementation: Implementation = .platformDefault) { self.session = session if case .streaming = implementation { precondition(Implementation.platformSupportsStreaming, "Streaming not supported on platform") @@ -352,7 +352,7 @@ extension URLSessionTransport.Configuration.Implementation { #endif } - static var platformDefault: Self { + public static var platformDefault: Self { guard platformSupportsStreaming else { return .buffering } return .streaming( requestBodyStreamBufferSize: 16 * 1024, From e0b007b80f46d91978f3a0a81e0f609270224a5b Mon Sep 17 00:00:00 2001 From: Patrick Wolowicz Date: Wed, 26 Mar 2025 15:12:52 +0100 Subject: [PATCH 02/15] Adding HTTPBodyProcessingMode --- .../URLSessionTransport.swift | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/Sources/OpenAPIURLSession/URLSessionTransport.swift b/Sources/OpenAPIURLSession/URLSessionTransport.swift index 56deb8b..a061051 100644 --- a/Sources/OpenAPIURLSession/URLSessionTransport.swift +++ b/Sources/OpenAPIURLSession/URLSessionTransport.swift @@ -70,15 +70,41 @@ public struct URLSessionTransport: ClientTransport { /// - Parameter session: The URLSession used for performing HTTP operations. /// If none is provided, the system uses the shared URLSession. public init(session: URLSession = .shared) { self.init(session: session, implementation: .platformDefault) } + + /// Specifies the mode in which HTTP request and response bodies are processed. + public enum HTTPBodyProcessingMode { + /// Processes the HTTP body incrementally as bytes become available. + /// + /// Use this mode to handle large payloads efficiently or to begin processing + /// before the entire body has been received. Will throw a `URLSessionTransportError.streamingNotSupported` + /// error if not available on the platform. + case streamed - public enum Implementation: Sendable { + /// Waits until the entire HTTP body has been received before processing begins. + /// + /// Use this mode when it's necessary or simpler to handle complete data payloads at once. + case buffered + } + + public init(session: URLSession = .shared, httpBodyProcessingMode: HTTPBodyProcessingMode) { + self.session = session + switch httpBodyProcessingMode { + + case .streamed: + self.implementation = .defaultStreaming + case .buffered: + self.implementation = .buffering + } + } + + enum Implementation: Sendable { case buffering case streaming(requestBodyStreamBufferSize: Int, responseBodyStreamWatermarks: (low: Int, high: Int)) } - public var implementation: Implementation + var implementation: Implementation - public init(session: URLSession = .shared, implementation: Implementation = .platformDefault) { + init(session: URLSession = .shared, implementation: Implementation = .platformDefault) { self.session = session if case .streaming = implementation { precondition(Implementation.platformSupportsStreaming, "Streaming not supported on platform") @@ -354,7 +380,11 @@ extension URLSessionTransport.Configuration.Implementation { public static var platformDefault: Self { guard platformSupportsStreaming else { return .buffering } - return .streaming( + return .defaultStreaming + } + + static var defaultStreaming: Self { + .streaming( requestBodyStreamBufferSize: 16 * 1024, responseBodyStreamWatermarks: (low: 16 * 1024, high: 32 * 1024) ) From 9fd926aa39fd3d4eb9f6ae1c2d707b27c9c2e649 Mon Sep 17 00:00:00 2001 From: Patrick Wolowicz Date: Wed, 26 Mar 2025 15:15:37 +0100 Subject: [PATCH 03/15] Making platformDefault private again --- Sources/OpenAPIURLSession/URLSessionTransport.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/OpenAPIURLSession/URLSessionTransport.swift b/Sources/OpenAPIURLSession/URLSessionTransport.swift index a061051..46077bb 100644 --- a/Sources/OpenAPIURLSession/URLSessionTransport.swift +++ b/Sources/OpenAPIURLSession/URLSessionTransport.swift @@ -378,7 +378,7 @@ extension URLSessionTransport.Configuration.Implementation { #endif } - public static var platformDefault: Self { + static var platformDefault: Self { guard platformSupportsStreaming else { return .buffering } return .defaultStreaming } From a3d13fb95c9d4ca8d71780ff9e75baba3fc3036a Mon Sep 17 00:00:00 2001 From: Patrick Wolowicz Date: Wed, 26 Mar 2025 15:16:51 +0100 Subject: [PATCH 04/15] Making platformDefault private again --- Sources/OpenAPIURLSession/URLSessionTransport.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/OpenAPIURLSession/URLSessionTransport.swift b/Sources/OpenAPIURLSession/URLSessionTransport.swift index 46077bb..6dfbfdd 100644 --- a/Sources/OpenAPIURLSession/URLSessionTransport.swift +++ b/Sources/OpenAPIURLSession/URLSessionTransport.swift @@ -97,7 +97,7 @@ public struct URLSessionTransport: ClientTransport { } } - enum Implementation: Sendable { + enum Implementation { case buffering case streaming(requestBodyStreamBufferSize: Int, responseBodyStreamWatermarks: (low: Int, high: Int)) } From d62e3cf2639e98068ac568b48538e0fa24a2e117 Mon Sep 17 00:00:00 2001 From: Patrick Wolowicz Date: Wed, 26 Mar 2025 17:37:22 +0100 Subject: [PATCH 05/15] linting --- .../OpenAPIURLSession/URLSessionTransport.swift | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Sources/OpenAPIURLSession/URLSessionTransport.swift b/Sources/OpenAPIURLSession/URLSessionTransport.swift index 6dfbfdd..ebd482a 100644 --- a/Sources/OpenAPIURLSession/URLSessionTransport.swift +++ b/Sources/OpenAPIURLSession/URLSessionTransport.swift @@ -70,7 +70,6 @@ public struct URLSessionTransport: ClientTransport { /// - Parameter session: The URLSession used for performing HTTP operations. /// If none is provided, the system uses the shared URLSession. public init(session: URLSession = .shared) { self.init(session: session, implementation: .platformDefault) } - /// Specifies the mode in which HTTP request and response bodies are processed. public enum HTTPBodyProcessingMode { /// Processes the HTTP body incrementally as bytes become available. @@ -85,15 +84,15 @@ public struct URLSessionTransport: ClientTransport { /// Use this mode when it's necessary or simpler to handle complete data payloads at once. case buffered } - + /// Creates a new configuration with the provided session. + /// - Parameters: + /// - session: The URLSession used for performing HTTP operations. + /// - httpBodyProcessingMode: The mode used to process HTTP request and response bodies. public init(session: URLSession = .shared, httpBodyProcessingMode: HTTPBodyProcessingMode) { self.session = session switch httpBodyProcessingMode { - - case .streamed: - self.implementation = .defaultStreaming - case .buffered: - self.implementation = .buffering + case .streamed: self.implementation = .defaultStreaming + case .buffered: self.implementation = .buffering } } @@ -382,7 +381,6 @@ extension URLSessionTransport.Configuration.Implementation { guard platformSupportsStreaming else { return .buffering } return .defaultStreaming } - static var defaultStreaming: Self { .streaming( requestBodyStreamBufferSize: 16 * 1024, From adb6c07401eb7e8b8eb6714a095fd2c99a291996 Mon Sep 17 00:00:00 2001 From: Patrick Wolowicz Date: Fri, 28 Mar 2025 13:17:01 +0100 Subject: [PATCH 06/15] moving HTTPBodyProcessingMode from public enum to public struct --- .../URLSessionTransport.swift | 46 +++++++++---------- 1 file changed, 21 insertions(+), 25 deletions(-) diff --git a/Sources/OpenAPIURLSession/URLSessionTransport.swift b/Sources/OpenAPIURLSession/URLSessionTransport.swift index ebd482a..c496b2b 100644 --- a/Sources/OpenAPIURLSession/URLSessionTransport.swift +++ b/Sources/OpenAPIURLSession/URLSessionTransport.swift @@ -67,33 +67,36 @@ public struct URLSessionTransport: ClientTransport { public var session: URLSession /// Creates a new configuration with the provided session. - /// - Parameter session: The URLSession used for performing HTTP operations. - /// If none is provided, the system uses the shared URLSession. - public init(session: URLSession = .shared) { self.init(session: session, implementation: .platformDefault) } + /// - Parameters: + /// - session: The URLSession used for performing HTTP operations. + /// - httpBodyProcessingMode: The mode used to process HTTP request and response bodies. + public init(session: URLSession = .shared, httpBodyProcessingMode: HTTPBodyProcessingMode = .platformDefault) { + self.session = session + let implementation = httpBodyProcessingMode.implementation + if case .streaming = implementation { + precondition(Implementation.platformSupportsStreaming, "Streaming not supported on platform") + } + self.implementation = implementation + } /// Specifies the mode in which HTTP request and response bodies are processed. - public enum HTTPBodyProcessingMode { + public struct HTTPBodyProcessingMode { + /// Exposing the internal implementation directly. + fileprivate let implementation: Configuration.Implementation + + private init(_ implementation: Configuration.Implementation) { self.implementation = implementation } + /// Processes the HTTP body incrementally as bytes become available. /// /// Use this mode to handle large payloads efficiently or to begin processing /// before the entire body has been received. Will throw a `URLSessionTransportError.streamingNotSupported` /// error if not available on the platform. - case streamed - + public static let streamed = HTTPBodyProcessingMode(.defaultStreaming) /// Waits until the entire HTTP body has been received before processing begins. /// /// Use this mode when it's necessary or simpler to handle complete data payloads at once. - case buffered - } - /// Creates a new configuration with the provided session. - /// - Parameters: - /// - session: The URLSession used for performing HTTP operations. - /// - httpBodyProcessingMode: The mode used to process HTTP request and response bodies. - public init(session: URLSession = .shared, httpBodyProcessingMode: HTTPBodyProcessingMode) { - self.session = session - switch httpBodyProcessingMode { - case .streamed: self.implementation = .defaultStreaming - case .buffered: self.implementation = .buffering - } + public static let buffered = HTTPBodyProcessingMode(.buffering) + /// Automatically chooses the optimal transport mode, based on the platform being used. + public static let platformDefault = HTTPBodyProcessingMode(.platformDefault) } enum Implementation { @@ -103,13 +106,6 @@ public struct URLSessionTransport: ClientTransport { var implementation: Implementation - init(session: URLSession = .shared, implementation: Implementation = .platformDefault) { - self.session = session - if case .streaming = implementation { - precondition(Implementation.platformSupportsStreaming, "Streaming not supported on platform") - } - self.implementation = implementation - } } /// A set of configuration values used by the transport. From a1b1562bbd1217b7a9d65daad5e31515e025ed0a Mon Sep 17 00:00:00 2001 From: Patrick Wolowicz Date: Tue, 1 Apr 2025 13:18:02 +0200 Subject: [PATCH 07/15] removing .streamed HTTPBodyProcessingMode --- .../URLSessionTransport.swift | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/Sources/OpenAPIURLSession/URLSessionTransport.swift b/Sources/OpenAPIURLSession/URLSessionTransport.swift index c496b2b..4cb564b 100644 --- a/Sources/OpenAPIURLSession/URLSessionTransport.swift +++ b/Sources/OpenAPIURLSession/URLSessionTransport.swift @@ -85,17 +85,10 @@ public struct URLSessionTransport: ClientTransport { private init(_ implementation: Configuration.Implementation) { self.implementation = implementation } - /// Processes the HTTP body incrementally as bytes become available. - /// - /// Use this mode to handle large payloads efficiently or to begin processing - /// before the entire body has been received. Will throw a `URLSessionTransportError.streamingNotSupported` - /// error if not available on the platform. - public static let streamed = HTTPBodyProcessingMode(.defaultStreaming) - /// Waits until the entire HTTP body has been received before processing begins. - /// - /// Use this mode when it's necessary or simpler to handle complete data payloads at once. + /// Use this mode to force URLSessionTransport to transfer data in a buffered mode, even if + /// streaming would be available on the platform. public static let buffered = HTTPBodyProcessingMode(.buffering) - /// Automatically chooses the optimal transport mode, based on the platform being used. + /// Data is transfered via streaming if available on the platform, else it falls back to buffering. public static let platformDefault = HTTPBodyProcessingMode(.platformDefault) } @@ -375,10 +368,7 @@ extension URLSessionTransport.Configuration.Implementation { static var platformDefault: Self { guard platformSupportsStreaming else { return .buffering } - return .defaultStreaming - } - static var defaultStreaming: Self { - .streaming( + return .streaming( requestBodyStreamBufferSize: 16 * 1024, responseBodyStreamWatermarks: (low: 16 * 1024, high: 32 * 1024) ) From fb49a886adac00cd5d2db5bd5c74b327629420b1 Mon Sep 17 00:00:00 2001 From: Patrick Wolowicz Date: Tue, 1 Apr 2025 15:08:42 +0200 Subject: [PATCH 08/15] fixing testing issues --- .../URLSessionTransport.swift | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Sources/OpenAPIURLSession/URLSessionTransport.swift b/Sources/OpenAPIURLSession/URLSessionTransport.swift index 4cb564b..a2c6ba8 100644 --- a/Sources/OpenAPIURLSession/URLSessionTransport.swift +++ b/Sources/OpenAPIURLSession/URLSessionTransport.swift @@ -71,15 +71,12 @@ public struct URLSessionTransport: ClientTransport { /// - session: The URLSession used for performing HTTP operations. /// - httpBodyProcessingMode: The mode used to process HTTP request and response bodies. public init(session: URLSession = .shared, httpBodyProcessingMode: HTTPBodyProcessingMode = .platformDefault) { - self.session = session let implementation = httpBodyProcessingMode.implementation - if case .streaming = implementation { - precondition(Implementation.platformSupportsStreaming, "Streaming not supported on platform") - } - self.implementation = implementation + self.init(session: session, implementation: implementation) } /// Specifies the mode in which HTTP request and response bodies are processed. - public struct HTTPBodyProcessingMode { + + public struct HTTPBodyProcessingMode: Sendable { /// Exposing the internal implementation directly. fileprivate let implementation: Configuration.Implementation @@ -98,6 +95,14 @@ public struct URLSessionTransport: ClientTransport { } var implementation: Implementation + + init(session: URLSession = .shared, implementation: Implementation = .platformDefault) { + self.session = session + if case .streaming = implementation { + precondition(Implementation.platformSupportsStreaming, "Streaming not supported on platform") + } + self.implementation = implementation + } } @@ -106,7 +111,7 @@ public struct URLSessionTransport: ClientTransport { /// Creates a new URLSession-based transport. /// - Parameter configuration: A set of configuration values used by the transport. - public init(configuration: Configuration = .init()) { self.configuration = configuration } + public init(configuration: Configuration = .init(httpBodyProcessingMode: .platformDefault)) { self.configuration = configuration } /// Sends the underlying HTTP request and returns the received HTTP response. /// - Parameters: From 9df230c233d85b0097490d83973f4c803f02e9a8 Mon Sep 17 00:00:00 2001 From: Patrick Wolowicz Date: Tue, 1 Apr 2025 15:09:28 +0200 Subject: [PATCH 09/15] fixing testing issues --- Sources/OpenAPIURLSession/URLSessionTransport.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Sources/OpenAPIURLSession/URLSessionTransport.swift b/Sources/OpenAPIURLSession/URLSessionTransport.swift index a2c6ba8..57802f9 100644 --- a/Sources/OpenAPIURLSession/URLSessionTransport.swift +++ b/Sources/OpenAPIURLSession/URLSessionTransport.swift @@ -75,7 +75,7 @@ public struct URLSessionTransport: ClientTransport { self.init(session: session, implementation: implementation) } /// Specifies the mode in which HTTP request and response bodies are processed. - + public struct HTTPBodyProcessingMode: Sendable { /// Exposing the internal implementation directly. fileprivate let implementation: Configuration.Implementation @@ -95,7 +95,6 @@ public struct URLSessionTransport: ClientTransport { } var implementation: Implementation - init(session: URLSession = .shared, implementation: Implementation = .platformDefault) { self.session = session if case .streaming = implementation { @@ -111,7 +110,9 @@ public struct URLSessionTransport: ClientTransport { /// Creates a new URLSession-based transport. /// - Parameter configuration: A set of configuration values used by the transport. - public init(configuration: Configuration = .init(httpBodyProcessingMode: .platformDefault)) { self.configuration = configuration } + public init(configuration: Configuration = .init(httpBodyProcessingMode: .platformDefault)) { + self.configuration = configuration + } /// Sends the underlying HTTP request and returns the received HTTP response. /// - Parameters: From 2f280f00f797343a77c90c16d79b5696d1f7bdce Mon Sep 17 00:00:00 2001 From: Patrick Wolowicz Date: Tue, 1 Apr 2025 21:56:59 +0200 Subject: [PATCH 10/15] explicitly keeping init(session:) --- Sources/OpenAPIURLSession/URLSessionTransport.swift | 4 +++- Tests/OpenAPIURLSessionTests/TaskCancellationTests.swift | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Sources/OpenAPIURLSession/URLSessionTransport.swift b/Sources/OpenAPIURLSession/URLSessionTransport.swift index 57802f9..56bfbab 100644 --- a/Sources/OpenAPIURLSession/URLSessionTransport.swift +++ b/Sources/OpenAPIURLSession/URLSessionTransport.swift @@ -74,8 +74,10 @@ public struct URLSessionTransport: ClientTransport { let implementation = httpBodyProcessingMode.implementation self.init(session: session, implementation: implementation) } + /// Creates a new configuration with the provided session. + /// - Parameter session: The URLSession used for performing HTTP operations. + public init(session: URLSession) { self.init(session: session, implementation: .platformDefault) } /// Specifies the mode in which HTTP request and response bodies are processed. - public struct HTTPBodyProcessingMode: Sendable { /// Exposing the internal implementation directly. fileprivate let implementation: Configuration.Implementation diff --git a/Tests/OpenAPIURLSessionTests/TaskCancellationTests.swift b/Tests/OpenAPIURLSessionTests/TaskCancellationTests.swift index a5f4c86..31b2d74 100644 --- a/Tests/OpenAPIURLSessionTests/TaskCancellationTests.swift +++ b/Tests/OpenAPIURLSessionTests/TaskCancellationTests.swift @@ -18,6 +18,7 @@ import HTTPTypes import NIO import OpenAPIRuntime import XCTest +import NIOHTTP1 @testable import OpenAPIURLSession enum CancellationPoint: CaseIterable { From 57dfdebb983db663fd23c8f5ce7084693c3a2f2c Mon Sep 17 00:00:00 2001 From: Patrick Wolowicz Date: Tue, 1 Apr 2025 22:05:00 +0200 Subject: [PATCH 11/15] improving comments --- Sources/OpenAPIURLSession/URLSessionTransport.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Sources/OpenAPIURLSession/URLSessionTransport.swift b/Sources/OpenAPIURLSession/URLSessionTransport.swift index 56bfbab..a0ddb56 100644 --- a/Sources/OpenAPIURLSession/URLSessionTransport.swift +++ b/Sources/OpenAPIURLSession/URLSessionTransport.swift @@ -69,6 +69,7 @@ public struct URLSessionTransport: ClientTransport { /// Creates a new configuration with the provided session. /// - Parameters: /// - session: The URLSession used for performing HTTP operations. + /// If none is provided, the system uses the shared URLSession. /// - httpBodyProcessingMode: The mode used to process HTTP request and response bodies. public init(session: URLSession = .shared, httpBodyProcessingMode: HTTPBodyProcessingMode = .platformDefault) { let implementation = httpBodyProcessingMode.implementation @@ -76,6 +77,7 @@ public struct URLSessionTransport: ClientTransport { } /// Creates a new configuration with the provided session. /// - Parameter session: The URLSession used for performing HTTP operations. + /// If none is provided, the system uses the shared URLSession. public init(session: URLSession) { self.init(session: session, implementation: .platformDefault) } /// Specifies the mode in which HTTP request and response bodies are processed. public struct HTTPBodyProcessingMode: Sendable { From 43fd210895c40431bb5d3946c59c7e27e91543e1 Mon Sep 17 00:00:00 2001 From: Patrick Wolowicz Date: Tue, 1 Apr 2025 22:08:26 +0200 Subject: [PATCH 12/15] improving comments --- Sources/OpenAPIURLSession/URLSessionTransport.swift | 4 ++-- Tests/OpenAPIURLSessionTests/TaskCancellationTests.swift | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Sources/OpenAPIURLSession/URLSessionTransport.swift b/Sources/OpenAPIURLSession/URLSessionTransport.swift index a0ddb56..abd905c 100644 --- a/Sources/OpenAPIURLSession/URLSessionTransport.swift +++ b/Sources/OpenAPIURLSession/URLSessionTransport.swift @@ -69,7 +69,7 @@ public struct URLSessionTransport: ClientTransport { /// Creates a new configuration with the provided session. /// - Parameters: /// - session: The URLSession used for performing HTTP operations. - /// If none is provided, the system uses the shared URLSession. + /// If none is provided, the system uses the shared URLSession. /// - httpBodyProcessingMode: The mode used to process HTTP request and response bodies. public init(session: URLSession = .shared, httpBodyProcessingMode: HTTPBodyProcessingMode = .platformDefault) { let implementation = httpBodyProcessingMode.implementation @@ -77,7 +77,7 @@ public struct URLSessionTransport: ClientTransport { } /// Creates a new configuration with the provided session. /// - Parameter session: The URLSession used for performing HTTP operations. - /// If none is provided, the system uses the shared URLSession. + /// If none is provided, the system uses the shared URLSession. public init(session: URLSession) { self.init(session: session, implementation: .platformDefault) } /// Specifies the mode in which HTTP request and response bodies are processed. public struct HTTPBodyProcessingMode: Sendable { diff --git a/Tests/OpenAPIURLSessionTests/TaskCancellationTests.swift b/Tests/OpenAPIURLSessionTests/TaskCancellationTests.swift index 31b2d74..a5f4c86 100644 --- a/Tests/OpenAPIURLSessionTests/TaskCancellationTests.swift +++ b/Tests/OpenAPIURLSessionTests/TaskCancellationTests.swift @@ -18,7 +18,6 @@ import HTTPTypes import NIO import OpenAPIRuntime import XCTest -import NIOHTTP1 @testable import OpenAPIURLSession enum CancellationPoint: CaseIterable { From 5617c4db28a7cf8f7d13f751aaf570d062edf0f5 Mon Sep 17 00:00:00 2001 From: Patrick Wolowicz Date: Tue, 1 Apr 2025 22:12:04 +0200 Subject: [PATCH 13/15] adding .shared --- Sources/OpenAPIURLSession/URLSessionTransport.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/OpenAPIURLSession/URLSessionTransport.swift b/Sources/OpenAPIURLSession/URLSessionTransport.swift index abd905c..634b605 100644 --- a/Sources/OpenAPIURLSession/URLSessionTransport.swift +++ b/Sources/OpenAPIURLSession/URLSessionTransport.swift @@ -78,7 +78,7 @@ public struct URLSessionTransport: ClientTransport { /// Creates a new configuration with the provided session. /// - Parameter session: The URLSession used for performing HTTP operations. /// If none is provided, the system uses the shared URLSession. - public init(session: URLSession) { self.init(session: session, implementation: .platformDefault) } + public init(session: URLSession = .shared) { self.init(session: session, implementation: .platformDefault) } /// Specifies the mode in which HTTP request and response bodies are processed. public struct HTTPBodyProcessingMode: Sendable { /// Exposing the internal implementation directly. From 9fd56c1a23a16a4b9b5deb6d5fb974327db19ecb Mon Sep 17 00:00:00 2001 From: Patrick Wolowicz Date: Tue, 1 Apr 2025 22:18:44 +0200 Subject: [PATCH 14/15] removing unneeded change to URLSessionTransport init --- Sources/OpenAPIURLSession/URLSessionTransport.swift | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Sources/OpenAPIURLSession/URLSessionTransport.swift b/Sources/OpenAPIURLSession/URLSessionTransport.swift index 634b605..a51aeb7 100644 --- a/Sources/OpenAPIURLSession/URLSessionTransport.swift +++ b/Sources/OpenAPIURLSession/URLSessionTransport.swift @@ -114,9 +114,7 @@ public struct URLSessionTransport: ClientTransport { /// Creates a new URLSession-based transport. /// - Parameter configuration: A set of configuration values used by the transport. - public init(configuration: Configuration = .init(httpBodyProcessingMode: .platformDefault)) { - self.configuration = configuration - } + public init(configuration: Configuration = .init()) { self.configuration = configuration } /// Sends the underlying HTTP request and returns the received HTTP response. /// - Parameters: From 1a685fc90076b2791d3ef9bd2aac7e5c6d00a575 Mon Sep 17 00:00:00 2001 From: Patrick Wolowicz Date: Tue, 1 Apr 2025 22:21:52 +0200 Subject: [PATCH 15/15] removing whitespace changes --- Sources/OpenAPIURLSession/URLSessionTransport.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/OpenAPIURLSession/URLSessionTransport.swift b/Sources/OpenAPIURLSession/URLSessionTransport.swift index a51aeb7..5b8b269 100644 --- a/Sources/OpenAPIURLSession/URLSessionTransport.swift +++ b/Sources/OpenAPIURLSession/URLSessionTransport.swift @@ -99,6 +99,7 @@ public struct URLSessionTransport: ClientTransport { } var implementation: Implementation + init(session: URLSession = .shared, implementation: Implementation = .platformDefault) { self.session = session if case .streaming = implementation { @@ -106,7 +107,6 @@ public struct URLSessionTransport: ClientTransport { } self.implementation = implementation } - } /// A set of configuration values used by the transport.