@@ -66,10 +66,32 @@ public struct URLSessionTransport: ClientTransport {
6666 /// The URLSession used for performing HTTP operations.
6767 public var session : URLSession
6868
69+ /// Creates a new configuration with the provided session.
70+ /// - Parameters:
71+ /// - session: The URLSession used for performing HTTP operations.
72+ /// If none is provided, the system uses the shared URLSession.
73+ /// - httpBodyProcessingMode: The mode used to process HTTP request and response bodies.
74+ public init ( session: URLSession = . shared, httpBodyProcessingMode: HTTPBodyProcessingMode = . platformDefault) {
75+ let implementation = httpBodyProcessingMode. implementation
76+ self . init ( session: session, implementation: implementation)
77+ }
6978 /// Creates a new configuration with the provided session.
7079 /// - Parameter session: The URLSession used for performing HTTP operations.
7180 /// If none is provided, the system uses the shared URLSession.
7281 public init ( session: URLSession = . shared) { self . init ( session: session, implementation: . platformDefault) }
82+ /// Specifies the mode in which HTTP request and response bodies are processed.
83+ public struct HTTPBodyProcessingMode : Sendable {
84+ /// Exposing the internal implementation directly.
85+ fileprivate let implementation : Configuration . Implementation
86+
87+ private init ( _ implementation: Configuration . Implementation ) { self . implementation = implementation }
88+
89+ /// Use this mode to force URLSessionTransport to transfer data in a buffered mode, even if
90+ /// streaming would be available on the platform.
91+ public static let buffered = HTTPBodyProcessingMode ( . buffering)
92+ /// Data is transfered via streaming if available on the platform, else it falls back to buffering.
93+ public static let platformDefault = HTTPBodyProcessingMode ( . platformDefault)
94+ }
7395
7496 enum Implementation {
7597 case buffering
0 commit comments