Skip to content

Commit 71806bf

Browse files
authored
Merge pull request #6 from MFB-Technologies-Inc/bugfix/async-beta-does-not-support-urlsessiondelegate
2 parents c8ffdc2 + 39a21c9 commit 71806bf

File tree

56 files changed

+90
-88
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+90
-88
lines changed

.github/workflows/ci.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,20 @@ jobs:
2121
- '12.5.1'
2222
- '13.2'
2323
- '13.4'
24-
- '14.0'
24+
- '14.0.1'
25+
- '14.1'
26+
- '14.2'
2527
exclude:
2628
- os: macos-11
2729
xcode: '13.2'
2830
- os: macos-11
2931
xcode: '13.4'
3032
- os: macos-11
31-
xcode: '14.0'
33+
xcode: '14.0.1'
34+
- os: macos-11
35+
xcode: '14.1'
36+
- os: macos-11
37+
xcode: '14.2'
3238
- os: macos-12
3339
xcode: '12.4'
3440
- os: macos-12

Package.resolved

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
"repositoryURL": "https://github.com/pointfreeco/combine-schedulers.git",
77
"state": {
88
"branch": null,
9-
"revision": "aa3e575929f2bcc5bad012bd2575eae716cbcdf7",
10-
"version": "0.8.0"
9+
"revision": "882ac01eb7ef9e36d4467eb4b1151e74fcef85ab",
10+
"version": "0.9.1"
1111
}
1212
},
1313
{
@@ -24,8 +24,8 @@
2424
"repositoryURL": "https://github.com/pointfreeco/xctest-dynamic-overlay",
2525
"state": {
2626
"branch": null,
27-
"revision": "30314f1ece684dd60679d598a9b89107557b67d9",
28-
"version": "0.4.1"
27+
"revision": "ace21305e0dd3a9e749aef79fef14be79a3b4669",
28+
"version": "0.8.2"
2929
}
3030
}
3131
]

Sources/NetworkService/HTTPURLResponse+StatusCode.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// HTTPURLResponse+StatusCode.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkService/NetworkService.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// NetworkService.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkService/NetworkServiceClient+Delete.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// NetworkServiceClient+Delete.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkService/NetworkServiceClient+Get.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// NetworkServiceClient+Get.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkService/NetworkServiceClient+GetSession.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// NetworkServiceClient+GetSession.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkService/NetworkServiceClient+Post.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// NetworkServiceClient+Post.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkService/NetworkServiceClient+Put.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// NetworkServiceClient+Put.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkService/NetworkServiceClient+Start.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// NetworkServiceClient+Start.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkService/NetworkServiceClient+URLSessionDelegate.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// NetworkServiceClient+URLSessionDelegate.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkService/NetworkServiceClient.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// NetworkServiceClient.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkService/Publisher+NetworkService.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Publisher+NetworkService.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkService/TopLevelCodable.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// TopLevelCodable.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkService/URLRequest+HTTPHeader.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// URLRequest+HTTPHeader.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkService/URLRequest+HTTPMethod.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// URLRequest+HTTPMethod.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkServiceAsyncBeta/HTTPURLResponse+StatusCode.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// HTTPURLResponse+StatusCode.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkServiceAsyncBeta/NetworkService.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// NetworkService.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkServiceAsyncBeta/NetworkServiceClient+Delete.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// NetworkServiceClient+Delete.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkServiceAsyncBeta/NetworkServiceClient+Get.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// NetworkServiceClient+Get.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkServiceAsyncBeta/NetworkServiceClient+GetSession.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// NetworkServiceClient+GetSession.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkServiceAsyncBeta/NetworkServiceClient+Post.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// NetworkServiceClient+Post.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkServiceAsyncBeta/NetworkServiceClient+Put.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// NetworkServiceClient+Put.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkServiceAsyncBeta/NetworkServiceClient+Start.swift

+25-29
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// NetworkServiceClient+Start.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.
@@ -28,38 +28,34 @@ extension NetworkServiceClient {
2828

2929
private func response(_ request: URLRequest) async throws -> (Data, URLResponse) {
3030
let session = getSession()
31-
if #available(iOS 15, watchOS 8, macOS 12, macCatalyst 15, tvOS 15, *) {
32-
return try await session.data(for: request)
33-
} else {
34-
var task: URLSessionDataTask?
35-
var shouldCancel: Bool = false
36-
let onCancel = {
37-
if let task = task {
38-
task.cancel()
39-
} else {
40-
shouldCancel = true
41-
}
31+
var task: URLSessionDataTask?
32+
var shouldCancel: Bool = false
33+
let onCancel = {
34+
if let task = task {
35+
task.cancel()
36+
} else {
37+
shouldCancel = true
4238
}
43-
return try await withTaskCancellationHandler(
44-
handler: { onCancel() },
45-
operation: {
46-
try await withCheckedThrowingContinuation { continuation in
47-
task = session.dataTask(with: request, completionHandler: { _data, _urlResponse, _error in
48-
guard let data = _data, let urlResponse = _urlResponse else {
49-
return continuation.resume(throwing: _error ?? URLError(.badServerResponse))
50-
}
51-
continuation.resume(returning: (data, urlResponse))
52-
})
53-
54-
if shouldCancel {
55-
task?.cancel()
56-
} else {
57-
task?.resume()
39+
}
40+
return try await withTaskCancellationHandler(
41+
handler: { onCancel() },
42+
operation: {
43+
try await withCheckedThrowingContinuation { continuation in
44+
task = session.dataTask(with: request, completionHandler: { _data, _urlResponse, _error in
45+
guard let data = _data, let urlResponse = _urlResponse else {
46+
return continuation.resume(throwing: _error ?? URLError(.badServerResponse))
5847
}
48+
continuation.resume(returning: (data, urlResponse))
49+
})
50+
51+
if shouldCancel {
52+
task?.cancel()
53+
} else {
54+
task?.resume()
5955
}
6056
}
61-
)
62-
}
57+
}
58+
)
6359
}
6460
}
6561

Sources/NetworkServiceAsyncBeta/NetworkServiceClient.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// NetworkServiceClient.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkServiceAsyncBeta/Result+NetworkService.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Result+NetworkService.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkServiceAsyncBeta/TopLevelCodable.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// TopLevelCodable.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkServiceAsyncBeta/URLRequest+HTTPHeader.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// URLRequest+HTTPHeader.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkServiceAsyncBeta/URLRequest+HTTPMethod.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// URLRequest+HTTPMethod.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkServiceAsyncBeta/URLRequest+build.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// URLRequest+build.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkServiceTestHelper/MockNetworkService.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// MockNetworkService.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkServiceTestHelperAsyncBeta/CodableOutput.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// CodableOutput.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkServiceTestHelperAsyncBeta/Delay.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Delay.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

Sources/NetworkServiceTestHelperAsyncBeta/FailureOutput.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// FailureOutput.swift
22
// NetworkService
33
//
4-
// Copyright © 2022 MFB Technologies, Inc. All rights reserved.
4+
// Copyright © 2023 MFB Technologies, Inc. All rights reserved.
55
//
66
// This source code is licensed under the MIT license found in the
77
// LICENSE file in the root directory of this source tree.

0 commit comments

Comments
 (0)