Skip to content

Commit 237a186

Browse files
authored
Fix adapting a request during retry (#8)
Release `1.1.0-rc.2`
2 parents abf46c5 + 14ebd5b commit 237a186

File tree

5 files changed

+25
-29
lines changed

5 files changed

+25
-29
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ jobs:
2424
fail-fast: false
2525
matrix:
2626
include:
27-
- xcode: "Xcode_16.0"
27+
- xcode: "Xcode_16.1"
2828
runsOn: macOS-14
29-
name: "macOS 14, Xcode 16.0, Swift 6.0"
29+
name: "macOS 14, Xcode 16.1, Swift 6.0.2"
3030
- xcode: "Xcode_15.4"
3131
runsOn: macOS-14
3232
name: "macOS 14, Xcode 15.4, Swift 5.10"
@@ -61,10 +61,6 @@ jobs:
6161
name: "iOS 18.1"
6262
xcode: "Xcode_16.1"
6363
runsOn: macOS-14
64-
- destination: "OS=18.0,name=iPhone 16 Pro"
65-
name: "iOS 18.0"
66-
xcode: "Xcode_16.0"
67-
runsOn: macOS-14
6864
- destination: "OS=17.5,name=iPhone 15 Pro"
6965
name: "iOS 17.5"
7066
xcode: "Xcode_15.4"
@@ -102,10 +98,6 @@ jobs:
10298
name: "tvOS 18.1"
10399
xcode: "Xcode_16.1"
104100
runsOn: macOS-14
105-
- destination: "OS=18.0,name=Apple TV"
106-
name: "tvOS 18.0"
107-
xcode: "Xcode_16.0"
108-
runsOn: macOS-14
109101
- destination: "OS=17.5,name=Apple TV"
110102
name: "tvOS 17.5"
111103
xcode: "Xcode_15.4"
@@ -143,10 +135,6 @@ jobs:
143135
name: "watchOS 11.1"
144136
xcode: "Xcode_16.1"
145137
runsOn: macOS-14
146-
- destination: "OS=11.0,name=Apple Watch Series 10 (46mm)"
147-
name: "watchOS 11.0"
148-
xcode: "Xcode_16.0"
149-
runsOn: macOS-14
150138
- destination: "OS=10.5,name=Apple Watch Series 9 (45mm)"
151139
name: "watchOS 10.5"
152140
xcode: "Xcode_15.4"
@@ -183,9 +171,6 @@ jobs:
183171
- name: "macOS 14, SPM 6.0.2 Test"
184172
xcode: "Xcode_16.1"
185173
runsOn: macOS-14
186-
- name: "macOS 14, SPM 6.0.0 Test"
187-
xcode: "Xcode_16.0"
188-
runsOn: macOS-14
189174
- name: "macOS 14, SPM 5.9.0 Test"
190175
xcode: "Xcode_15.0"
191176
runsOn: macos-14

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file.
55
- `1.1.x` Release Candidates - [1.1.0-rc.1](#110-rc1)
66
- `1.0.x` Releases - [1.0.0](#100)
77

8+
## [1.1.0-rc.2](https://github.com/space-code/network-layer/releases/tag/1.1.0-rc.2)
9+
Released on 2025-05-30.
10+
11+
#### Fixed
12+
- Fix adapting a request during retry.
13+
- Fixed in Pull Request [#2](https://github.com/space-code/network-layer/pull/7).
14+
815
## [1.1.0-rc.1](https://github.com/space-code/network-layer/releases/tag/1.1.0-rc.1)
916
Released on 2024-12-25.
1017

@@ -16,7 +23,7 @@ Released on 2024-12-25.
1623
- Fix the `inout` parameter in the `IAuthenticator` protocol
1724
- Fixed in Pull Request [#2](https://github.com/space-code/network-layer/pull/2).
1825
- Fix the package builiding.
19-
- Fixed in Pull Request [#6](https://github.com/space-code/network-layer/pull-6).
26+
- Fixed in Pull Request [#6](https://github.com/space-code/network-layer/pull/6).
2027

2128
## [1.0.0](https://github.com/space-code/network-layer/releases/tag/1.0.0)
2229
Released on 2023-12-04.

Sources/NetworkLayer/Classes/Core/Services/RequestProcessor/RequestProcessor.swift

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// network-layer
3-
// Copyright © 2023 Space Code. All rights reserved.
3+
// Copyright © 2025 Space Code. All rights reserved.
44
//
55

66
import Foundation
@@ -75,15 +75,15 @@ actor RequestProcessor {
7575
_ request: T,
7676
strategy: RetryPolicyStrategy? = nil,
7777
delegate: URLSessionDelegate?,
78-
configure: ((inout URLRequest) throws -> Void)?
78+
configure: (@Sendable (inout URLRequest) throws -> Void)?
7979
) async throws -> Response<Data> {
80-
guard var urlRequest = try requestBuilder.build(request, configure) else {
81-
throw NetworkLayerError.badURL
82-
}
80+
try await performRequest(strategy: strategy) { [weak self] in
81+
guard let self, var urlRequest = try requestBuilder.build(request, configure) else {
82+
throw NetworkLayerError.badURL
83+
}
8384

84-
try await adapt(request, urlRequest: &urlRequest, session: session)
85+
try await adapt(request, urlRequest: &urlRequest, session: session)
8586

86-
return try await performRequest(strategy: strategy) { [urlRequest] in
8787
try await self.delegate?.wrappedValue?.requestProcessor(self, willSendRequest: urlRequest)
8888

8989
let task = session.dataTask(with: urlRequest)

Sources/NetworkLayerInterfaces/Classes/Core/Services/IRequestBuilder.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// network-layer
3-
// Copyright © 2023 Space Code. All rights reserved.
3+
// Copyright © 2025 Space Code. All rights reserved.
44
//
55

66
import Foundation
@@ -12,5 +12,5 @@ public protocol IRequestBuilder: Sendable {
1212
/// - Parameter request: The request object that defines the request details.
1313
///
1414
/// - Returns: A `URLRequest` constructed based on the given data.
15-
func build(_ request: IRequest, _ configure: ((inout URLRequest) throws -> Void)?) throws -> URLRequest?
15+
func build(_ request: IRequest, _ configure: (@Sendable (inout URLRequest) throws -> Void)?) throws -> URLRequest?
1616
}

Tests/NetworkLayerTests/Classes/Tests/IntegrationTests/RequestProcessorAuthenticationTests.swift

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//
22
// network-layer
3-
// Copyright © 2023 Space Code. All rights reserved.
3+
// Copyright © 2025 Space Code. All rights reserved.
44
//
55

66
import Foundation
@@ -60,7 +60,11 @@ final class RequestProcessorAuthenicationTests: XCTestCase {
6060
}
6161

6262
func test_thatRequestProcessorThrowsAnError_whenInterceptorAdaptDidFail() async throws {
63-
try await test_failAuthentication(adaptError: URLError(.unknown), refreshError: nil, expectedError: URLError(.unknown))
63+
try await test_failAuthentication(
64+
adaptError: URLError(.unknown),
65+
refreshError: nil,
66+
expectedError: RetryPolicyError.retryLimitExceeded
67+
)
6468
}
6569

6670
func test_thatRequestProcessorThrowsAnError_whenInterceptorRefreshDidFail() async throws {

0 commit comments

Comments
 (0)