@@ -66,10 +66,32 @@ public struct URLSessionTransport: ClientTransport {
66
66
/// The URLSession used for performing HTTP operations.
67
67
public var session : URLSession
68
68
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
+ }
69
78
/// Creates a new configuration with the provided session.
70
79
/// - Parameter session: The URLSession used for performing HTTP operations.
71
80
/// If none is provided, the system uses the shared URLSession.
72
81
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
+ }
73
95
74
96
enum Implementation {
75
97
case buffering
0 commit comments