File tree Expand file tree Collapse file tree 3 files changed +7
-3
lines changed
Expand file tree Collapse file tree 3 files changed +7
-3
lines changed Original file line number Diff line number Diff line change 11# APIClient 0.x
22
3+ ## Upcoming Release
4+
5+ - Make ` willSend ` async - [ #11 ] ( https://github.com/kean/APIClient/pull/11 ) , thanks to [ Lars-Jørgen Kristiansen] ( https://github.com/LarsJK )
6+
37## APIClient 0.0.6
48
59* Dec 13, 2021*
Original file line number Diff line number Diff line change 55import Foundation
66
77public protocol APIClientDelegate {
8- func client( _ client: APIClient , willSendRequest request: inout URLRequest )
8+ func client( _ client: APIClient , willSendRequest request: inout URLRequest ) async
99 func shouldClientRetry( _ client: APIClient , withError error: Error ) async -> Bool
1010 func client( _ client: APIClient , didReceiveInvalidResponse response: HTTPURLResponse , data: Data ) -> Error
1111}
@@ -104,7 +104,7 @@ public actor APIClient {
104104
105105 private func actuallySend( _ request: URLRequest ) async throws -> Response < Data > {
106106 var request = request
107- delegate. client ( self , willSendRequest: & request)
107+ await delegate. client ( self , willSendRequest: & request)
108108 let ( data, response) = try await session. data ( for: request, delegate: nil )
109109 try validate ( response: response, data: data)
110110 let httpResponse = ( response as? HTTPURLResponse ) ?? HTTPURLResponse ( ) // The right side should never be executed
Original file line number Diff line number Diff line change @@ -219,7 +219,7 @@ private func json(named name: String) -> Data {
219219private final class MockAuthorizatingDelegate : APIClientDelegate {
220220 var token = " expired-token "
221221
222- func client( _ client: APIClient , willSendRequest request: inout URLRequest ) {
222+ func client( _ client: APIClient , willSendRequest request: inout URLRequest ) async {
223223 request. allHTTPHeaderFields = [ " Authorization " : " Bearer: \( token) " ]
224224 }
225225
You can’t perform that action at this time.
0 commit comments