@@ -5,29 +5,30 @@ import FoundationNetworking
55#endif
66
77public protocol DataTask {
8- var state : URLSessionTask . State { get }
9- func resume( )
8+ var state : URLSessionTask . State { get }
9+ func resume( )
1010}
1111
1212public protocol UploadTask : DataTask { }
1313
1414// An enumeration of default `HTTPSession` configurations to be used
1515// This can be extended buy consumer to easily refer back to their configured session.
1616public enum HTTPSessions {
17- /// An implementation of `HTTPSession` backed by Apple's `URLSession`.
18- public static func urlSession( ) -> any HTTPSession {
19- let configuration = URLSessionConfiguration . ephemeral
20- configuration. httpMaximumConnectionsPerHost = 2
21- let session = URLSession ( configuration: configuration, delegate: nil , delegateQueue: nil )
22- return session
23- }
17+ /// An implementation of `HTTPSession` backed by Apple's `URLSession`.
18+ public static func urlSession( ) -> any HTTPSession {
19+ let configuration = URLSessionConfiguration . ephemeral
20+ configuration. httpMaximumConnectionsPerHost = 2
21+ let session = URLSession ( configuration: configuration, delegate: nil , delegateQueue: nil )
22+ return session
23+ }
2424}
2525
2626public protocol HTTPSession {
27- associatedtype DataTaskType : DataTask
28- associatedtype UploadTaskType : UploadTask
29-
30- func uploadTask( with request: URLRequest , fromFile file: URL , completionHandler: @escaping @Sendable ( Data ? , URLResponse ? , ( any Error ) ? ) -> Void ) -> UploadTaskType
31- func dataTask( with request: URLRequest , completionHandler: @escaping @Sendable ( Data ? , URLResponse ? , ( any Error ) ? ) -> Void ) -> DataTaskType
32- func finishTasksAndInvalidate( )
27+ associatedtype DataTaskType : DataTask
28+ associatedtype UploadTaskType : UploadTask
29+
30+ func uploadTask( with request: URLRequest , fromFile file: URL , completionHandler: @escaping @Sendable ( Data ? , URLResponse ? , ( any Error ) ? ) -> Void ) -> UploadTaskType
31+ func uploadTask( with request: URLRequest , from bodyData: Data ? , completionHandler: @escaping @Sendable ( Data ? , URLResponse ? , ( any Error ) ? ) -> Void ) -> UploadTaskType
32+ func dataTask( with request: URLRequest , completionHandler: @escaping @Sendable ( Data ? , URLResponse ? , ( any Error ) ? ) -> Void ) -> DataTaskType
33+ func finishTasksAndInvalidate( )
3334}
0 commit comments