diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d56943c..a607172 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,9 +24,9 @@ jobs: fail-fast: false matrix: include: - - xcode: "Xcode_16.0" + - xcode: "Xcode_16.1" runsOn: macOS-14 - name: "macOS 14, Xcode 16.0, Swift 6.0" + name: "macOS 14, Xcode 16.1, Swift 6.0.2" - xcode: "Xcode_15.4" runsOn: macOS-14 name: "macOS 14, Xcode 15.4, Swift 5.10" @@ -61,10 +61,6 @@ jobs: name: "iOS 18.1" xcode: "Xcode_16.1" runsOn: macOS-14 - - destination: "OS=18.0,name=iPhone 16 Pro" - name: "iOS 18.0" - xcode: "Xcode_16.0" - runsOn: macOS-14 - destination: "OS=17.5,name=iPhone 15 Pro" name: "iOS 17.5" xcode: "Xcode_15.4" @@ -102,10 +98,6 @@ jobs: name: "tvOS 18.1" xcode: "Xcode_16.1" runsOn: macOS-14 - - destination: "OS=18.0,name=Apple TV" - name: "tvOS 18.0" - xcode: "Xcode_16.0" - runsOn: macOS-14 - destination: "OS=17.5,name=Apple TV" name: "tvOS 17.5" xcode: "Xcode_15.4" @@ -143,10 +135,6 @@ jobs: name: "watchOS 11.1" xcode: "Xcode_16.1" runsOn: macOS-14 - - destination: "OS=11.0,name=Apple Watch Series 10 (46mm)" - name: "watchOS 11.0" - xcode: "Xcode_16.0" - runsOn: macOS-14 - destination: "OS=10.5,name=Apple Watch Series 9 (45mm)" name: "watchOS 10.5" xcode: "Xcode_15.4" @@ -183,9 +171,6 @@ jobs: - name: "macOS 14, SPM 6.0.2 Test" xcode: "Xcode_16.1" runsOn: macOS-14 - - name: "macOS 14, SPM 6.0.0 Test" - xcode: "Xcode_16.0" - runsOn: macOS-14 - name: "macOS 14, SPM 5.9.0 Test" xcode: "Xcode_15.0" runsOn: macos-14 diff --git a/CHANGELOG.md b/CHANGELOG.md index 79cae31..72129ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. - `1.1.x` Release Candidates - [1.1.0-rc.1](#110-rc1) - `1.0.x` Releases - [1.0.0](#100) +## [1.1.0-rc.2](https://github.com/space-code/network-layer/releases/tag/1.1.0-rc.2) +Released on 2025-05-30. + +#### Fixed +- Fix adapting a request during retry. + - Fixed in Pull Request [#2](https://github.com/space-code/network-layer/pull/7). + ## [1.1.0-rc.1](https://github.com/space-code/network-layer/releases/tag/1.1.0-rc.1) Released on 2024-12-25. @@ -16,7 +23,7 @@ Released on 2024-12-25. - Fix the `inout` parameter in the `IAuthenticator` protocol - Fixed in Pull Request [#2](https://github.com/space-code/network-layer/pull/2). - Fix the package builiding. - - Fixed in Pull Request [#6](https://github.com/space-code/network-layer/pull-6). + - Fixed in Pull Request [#6](https://github.com/space-code/network-layer/pull/6). ## [1.0.0](https://github.com/space-code/network-layer/releases/tag/1.0.0) Released on 2023-12-04. diff --git a/Sources/NetworkLayer/Classes/Core/Services/RequestProcessor/RequestProcessor.swift b/Sources/NetworkLayer/Classes/Core/Services/RequestProcessor/RequestProcessor.swift index 1375262..df5e5f7 100644 --- a/Sources/NetworkLayer/Classes/Core/Services/RequestProcessor/RequestProcessor.swift +++ b/Sources/NetworkLayer/Classes/Core/Services/RequestProcessor/RequestProcessor.swift @@ -1,6 +1,6 @@ // // network-layer -// Copyright © 2023 Space Code. All rights reserved. +// Copyright © 2025 Space Code. All rights reserved. // import Foundation @@ -75,15 +75,15 @@ actor RequestProcessor { _ request: T, strategy: RetryPolicyStrategy? = nil, delegate: URLSessionDelegate?, - configure: ((inout URLRequest) throws -> Void)? + configure: (@Sendable (inout URLRequest) throws -> Void)? ) async throws -> Response { - guard var urlRequest = try requestBuilder.build(request, configure) else { - throw NetworkLayerError.badURL - } + try await performRequest(strategy: strategy) { [weak self] in + guard let self, var urlRequest = try requestBuilder.build(request, configure) else { + throw NetworkLayerError.badURL + } - try await adapt(request, urlRequest: &urlRequest, session: session) + try await adapt(request, urlRequest: &urlRequest, session: session) - return try await performRequest(strategy: strategy) { [urlRequest] in try await self.delegate?.wrappedValue?.requestProcessor(self, willSendRequest: urlRequest) let task = session.dataTask(with: urlRequest) diff --git a/Sources/NetworkLayerInterfaces/Classes/Core/Services/IRequestBuilder.swift b/Sources/NetworkLayerInterfaces/Classes/Core/Services/IRequestBuilder.swift index dc3fb74..b615596 100644 --- a/Sources/NetworkLayerInterfaces/Classes/Core/Services/IRequestBuilder.swift +++ b/Sources/NetworkLayerInterfaces/Classes/Core/Services/IRequestBuilder.swift @@ -1,6 +1,6 @@ // // network-layer -// Copyright © 2023 Space Code. All rights reserved. +// Copyright © 2025 Space Code. All rights reserved. // import Foundation @@ -12,5 +12,5 @@ public protocol IRequestBuilder: Sendable { /// - Parameter request: The request object that defines the request details. /// /// - Returns: A `URLRequest` constructed based on the given data. - func build(_ request: IRequest, _ configure: ((inout URLRequest) throws -> Void)?) throws -> URLRequest? + func build(_ request: IRequest, _ configure: (@Sendable (inout URLRequest) throws -> Void)?) throws -> URLRequest? } diff --git a/Tests/NetworkLayerTests/Classes/Tests/IntegrationTests/RequestProcessorAuthenticationTests.swift b/Tests/NetworkLayerTests/Classes/Tests/IntegrationTests/RequestProcessorAuthenticationTests.swift index 81b4560..d45b568 100644 --- a/Tests/NetworkLayerTests/Classes/Tests/IntegrationTests/RequestProcessorAuthenticationTests.swift +++ b/Tests/NetworkLayerTests/Classes/Tests/IntegrationTests/RequestProcessorAuthenticationTests.swift @@ -1,6 +1,6 @@ // // network-layer -// Copyright © 2023 Space Code. All rights reserved. +// Copyright © 2025 Space Code. All rights reserved. // import Foundation @@ -60,7 +60,11 @@ final class RequestProcessorAuthenicationTests: XCTestCase { } func test_thatRequestProcessorThrowsAnError_whenInterceptorAdaptDidFail() async throws { - try await test_failAuthentication(adaptError: URLError(.unknown), refreshError: nil, expectedError: URLError(.unknown)) + try await test_failAuthentication( + adaptError: URLError(.unknown), + refreshError: nil, + expectedError: RetryPolicyError.retryLimitExceeded + ) } func test_thatRequestProcessorThrowsAnError_whenInterceptorRefreshDidFail() async throws {