diff --git a/Sources/AsyncHTTPClient/AsyncAwait/HTTPClient+execute.swift b/Sources/AsyncHTTPClient/AsyncAwait/HTTPClient+execute.swift index 3c0566c9e..6c45a590b 100644 --- a/Sources/AsyncHTTPClient/AsyncAwait/HTTPClient+execute.swift +++ b/Sources/AsyncHTTPClient/AsyncAwait/HTTPClient+execute.swift @@ -12,13 +12,13 @@ // //===----------------------------------------------------------------------===// -#if compiler(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.2) && canImport(_Concurrency) import struct Foundation.URL import Logging import NIOCore import NIOHTTP1 -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) extension HTTPClient { /// Execute arbitrary HTTP requests. /// @@ -41,7 +41,7 @@ extension HTTPClient { } } -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) extension HTTPClient { private func executeAndFollowRedirectsIfNeeded( _ request: HTTPClientRequest, @@ -124,7 +124,7 @@ extension HTTPClient { /// There is currently no good way to asynchronously cancel an object that is initiated inside the `body` closure of `with*Continuation`. /// As a workaround we use `TransactionCancelHandler` which will take care of the race between instantiation of `Transaction` /// in the `body` closure and cancelation from the `onCancel` closure of `withTaskCancellationHandler`. -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) private actor TransactionCancelHandler { enum CancelReason { /// swift concurrency task was canceled diff --git a/Sources/AsyncHTTPClient/AsyncAwait/HTTPClientRequest+Prepared.swift b/Sources/AsyncHTTPClient/AsyncAwait/HTTPClientRequest+Prepared.swift index 974616143..7899588e1 100644 --- a/Sources/AsyncHTTPClient/AsyncAwait/HTTPClientRequest+Prepared.swift +++ b/Sources/AsyncHTTPClient/AsyncAwait/HTTPClientRequest+Prepared.swift @@ -12,11 +12,11 @@ // //===----------------------------------------------------------------------===// -#if compiler(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.2) && canImport(_Concurrency) import struct Foundation.URL import NIOHTTP1 -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) extension HTTPClientRequest { struct Prepared { var url: URL @@ -27,7 +27,7 @@ extension HTTPClientRequest { } } -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) extension HTTPClientRequest.Prepared { init(_ request: HTTPClientRequest) throws { guard let url = URL(string: request.url) else { @@ -58,7 +58,7 @@ extension HTTPClientRequest.Prepared { } } -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) extension RequestBodyLength { init(_ body: HTTPClientRequest.Body?) { switch body?.mode { @@ -74,7 +74,7 @@ extension RequestBodyLength { } } -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) extension HTTPClientRequest.Prepared { func followingRedirect(to redirectURL: URL, status: HTTPResponseStatus) -> HTTPClientRequest { let (method, headers, body) = transformRequestForRedirect( diff --git a/Sources/AsyncHTTPClient/AsyncAwait/HTTPClientRequest.swift b/Sources/AsyncHTTPClient/AsyncAwait/HTTPClientRequest.swift index 3c729b75c..89689225d 100644 --- a/Sources/AsyncHTTPClient/AsyncAwait/HTTPClientRequest.swift +++ b/Sources/AsyncHTTPClient/AsyncAwait/HTTPClientRequest.swift @@ -12,11 +12,11 @@ // //===----------------------------------------------------------------------===// -#if compiler(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.2) && canImport(_Concurrency) import NIOCore import NIOHTTP1 -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) struct HTTPClientRequest { var url: String var method: HTTPMethod @@ -32,7 +32,7 @@ struct HTTPClientRequest { } } -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) extension HTTPClientRequest { struct Body { internal enum Mode { @@ -49,7 +49,7 @@ extension HTTPClientRequest { } } -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) extension HTTPClientRequest.Body { static func byteBuffer(_ byteBuffer: ByteBuffer) -> Self { self.init(.byteBuffer(byteBuffer)) @@ -131,7 +131,7 @@ extension HTTPClientRequest.Body { } } -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) extension Optional where Wrapped == HTTPClientRequest.Body { internal var canBeConsumedMultipleTimes: Bool { switch self?.mode { diff --git a/Sources/AsyncHTTPClient/AsyncAwait/HTTPClientResponse.swift b/Sources/AsyncHTTPClient/AsyncAwait/HTTPClientResponse.swift index 2df1b808c..1ecfed9e5 100644 --- a/Sources/AsyncHTTPClient/AsyncAwait/HTTPClientResponse.swift +++ b/Sources/AsyncHTTPClient/AsyncAwait/HTTPClientResponse.swift @@ -12,11 +12,11 @@ // //===----------------------------------------------------------------------===// -#if compiler(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.2) && canImport(_Concurrency) import NIOCore import NIOHTTP1 -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) struct HTTPClientResponse { var version: HTTPVersion var status: HTTPResponseStatus @@ -46,7 +46,7 @@ struct HTTPClientResponse { } } -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) extension HTTPClientResponse.Body: AsyncSequence { typealias Element = ByteBuffer typealias AsyncIterator = Iterator @@ -70,7 +70,7 @@ extension HTTPClientResponse.Body: AsyncSequence { } } -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) extension HTTPClientResponse.Body { /// The purpose of this object is to inform the transaction about the response body being deinitialized. /// If the users has not called `makeAsyncIterator` on the body, before it is deinited, the http @@ -88,7 +88,7 @@ extension HTTPClientResponse.Body { } } -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) extension HTTPClientResponse.Body { internal class IteratorStream { struct ID: Hashable { diff --git a/Sources/AsyncHTTPClient/AsyncAwait/Transaction+StateMachine.swift b/Sources/AsyncHTTPClient/AsyncAwait/Transaction+StateMachine.swift index 98fce4aed..dea1093db 100644 --- a/Sources/AsyncHTTPClient/AsyncAwait/Transaction+StateMachine.swift +++ b/Sources/AsyncHTTPClient/AsyncAwait/Transaction+StateMachine.swift @@ -11,12 +11,12 @@ // SPDX-License-Identifier: Apache-2.0 // //===----------------------------------------------------------------------===// -#if compiler(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.2) && canImport(_Concurrency) import Logging import NIOCore import NIOHTTP1 -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) extension Transaction { struct StateMachine { struct ExecutionContext { diff --git a/Sources/AsyncHTTPClient/AsyncAwait/Transaction.swift b/Sources/AsyncHTTPClient/AsyncAwait/Transaction.swift index f7a3ab03d..c2ce52eeb 100644 --- a/Sources/AsyncHTTPClient/AsyncAwait/Transaction.swift +++ b/Sources/AsyncHTTPClient/AsyncAwait/Transaction.swift @@ -12,14 +12,14 @@ // //===----------------------------------------------------------------------===// -#if compiler(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.2) && canImport(_Concurrency) import Logging import NIOConcurrencyHelpers import NIOCore import NIOHTTP1 import NIOSSL -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) final class Transaction: @unchecked Sendable { let logger: Logger @@ -145,7 +145,7 @@ final class Transaction: @unchecked Sendable { // MARK: - Protocol Methods - -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) extension Transaction: HTTPSchedulableRequest { var poolKey: ConnectionPool.Key { self.request.poolKey } var tlsConfiguration: TLSConfiguration? { return nil } @@ -158,7 +158,7 @@ extension Transaction: HTTPSchedulableRequest { } } -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) extension Transaction: HTTPExecutableRequest { var requestHead: HTTPRequestHead { self.request.head } @@ -316,7 +316,7 @@ extension Transaction: HTTPExecutableRequest { } } -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) extension Transaction { func responseBodyDeinited() { let deinitedAction = self.stateLock.withLock { diff --git a/Tests/AsyncHTTPClientTests/AsyncAwaitEndToEndTests.swift b/Tests/AsyncHTTPClientTests/AsyncAwaitEndToEndTests.swift index 7c5f61681..314695e97 100644 --- a/Tests/AsyncHTTPClientTests/AsyncAwaitEndToEndTests.swift +++ b/Tests/AsyncHTTPClientTests/AsyncAwaitEndToEndTests.swift @@ -34,8 +34,8 @@ private func makeDefaultHTTPClient( final class AsyncAwaitEndToEndTests: XCTestCase { func testSimpleGet() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { let bin = HTTPBin(.http2(compress: false)) defer { XCTAssertNoThrow(try bin.shutdown()) } @@ -57,8 +57,8 @@ final class AsyncAwaitEndToEndTests: XCTestCase { } func testSimplePost() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { let bin = HTTPBin(.http2(compress: false)) defer { XCTAssertNoThrow(try bin.shutdown()) } @@ -80,8 +80,8 @@ final class AsyncAwaitEndToEndTests: XCTestCase { } func testPostWithByteBuffer() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { let bin = HTTPBin(.http2(compress: false)) { _ in HTTPEchoHandler() } defer { XCTAssertNoThrow(try bin.shutdown()) } @@ -105,8 +105,8 @@ final class AsyncAwaitEndToEndTests: XCTestCase { } func testPostWithSequenceOfUInt8() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { let bin = HTTPBin(.http2(compress: false)) { _ in HTTPEchoHandler() } defer { XCTAssertNoThrow(try bin.shutdown()) } @@ -130,8 +130,8 @@ final class AsyncAwaitEndToEndTests: XCTestCase { } func testPostWithCollectionOfUInt8() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { let bin = HTTPBin(.http2(compress: false)) { _ in HTTPEchoHandler() } defer { XCTAssertNoThrow(try bin.shutdown()) } @@ -155,8 +155,8 @@ final class AsyncAwaitEndToEndTests: XCTestCase { } func testPostWithRandomAccessCollectionOfUInt8() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { let bin = HTTPBin(.http2(compress: false)) { _ in HTTPEchoHandler() } defer { XCTAssertNoThrow(try bin.shutdown()) } @@ -180,8 +180,8 @@ final class AsyncAwaitEndToEndTests: XCTestCase { } func testPostWithAsyncSequenceOfByteBuffers() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { let bin = HTTPBin(.http2(compress: false)) { _ in HTTPEchoHandler() } defer { XCTAssertNoThrow(try bin.shutdown()) } @@ -209,8 +209,8 @@ final class AsyncAwaitEndToEndTests: XCTestCase { } func testPostWithAsyncSequenceOfUInt8() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { let bin = HTTPBin(.http2(compress: false)) { _ in HTTPEchoHandler() } defer { XCTAssertNoThrow(try bin.shutdown()) } @@ -234,8 +234,8 @@ final class AsyncAwaitEndToEndTests: XCTestCase { } func testPostWithFragmentedAsyncSequenceOfByteBuffers() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { let bin = HTTPBin(.http2(compress: false)) { _ in HTTPEchoHandler() } defer { XCTAssertNoThrow(try bin.shutdown()) } @@ -276,8 +276,8 @@ final class AsyncAwaitEndToEndTests: XCTestCase { } func testPostWithFragmentedAsyncSequenceOfLargeByteBuffers() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { let bin = HTTPBin(.http2(compress: false)) { _ in HTTPEchoHandler() } defer { XCTAssertNoThrow(try bin.shutdown()) } @@ -319,8 +319,8 @@ final class AsyncAwaitEndToEndTests: XCTestCase { } func testCanceling() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest(timeout: 5) { let bin = HTTPBin(.http2(compress: false)) defer { XCTAssertNoThrow(try bin.shutdown()) } @@ -344,8 +344,8 @@ final class AsyncAwaitEndToEndTests: XCTestCase { } func testDeadline() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest(timeout: 5) { let bin = HTTPBin(.http2(compress: false)) defer { XCTAssertNoThrow(try bin.shutdown()) } @@ -365,8 +365,8 @@ final class AsyncAwaitEndToEndTests: XCTestCase { } func testImmediateDeadline() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest(timeout: 5) { let bin = HTTPBin(.http2(compress: false)) defer { XCTAssertNoThrow(try bin.shutdown()) } @@ -386,8 +386,8 @@ final class AsyncAwaitEndToEndTests: XCTestCase { } func testInvalidURL() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest(timeout: 5) { let client = makeDefaultHTTPClient() defer { XCTAssertNoThrow(try client.syncShutdown()) } @@ -402,7 +402,7 @@ final class AsyncAwaitEndToEndTests: XCTestCase { } } -#if compiler(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.2) && canImport(_Concurrency) extension AsyncSequence where Element == ByteBuffer { func collect() async rethrows -> ByteBuffer { try await self.reduce(into: ByteBuffer()) { accumulatingBuffer, nextBuffer in diff --git a/Tests/AsyncHTTPClientTests/AsyncTestHelpers.swift b/Tests/AsyncHTTPClientTests/AsyncTestHelpers.swift index 36813091f..312008959 100644 --- a/Tests/AsyncHTTPClientTests/AsyncTestHelpers.swift +++ b/Tests/AsyncHTTPClientTests/AsyncTestHelpers.swift @@ -12,11 +12,11 @@ // //===----------------------------------------------------------------------===// -#if swift(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.2) && canImport(_Concurrency) import NIOConcurrencyHelpers import NIOCore -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) class AsyncSequenceWriter: AsyncSequence { typealias AsyncIterator = Iterator diff --git a/Tests/AsyncHTTPClientTests/HTTPClientRequestTests.swift b/Tests/AsyncHTTPClientTests/HTTPClientRequestTests.swift index 082f37761..f47b0ef93 100644 --- a/Tests/AsyncHTTPClientTests/HTTPClientRequestTests.swift +++ b/Tests/AsyncHTTPClientTests/HTTPClientRequestTests.swift @@ -17,17 +17,17 @@ import NIOCore import XCTest class HTTPClientRequestTests: XCTestCase { - #if compiler(>=5.5) && canImport(_Concurrency) - @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) + #if compiler(>=5.5.2) && canImport(_Concurrency) + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) private typealias Request = HTTPClientRequest - @available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) private typealias PreparedRequest = HTTPClientRequest.Prepared #endif func testCustomHeadersAreRespected() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { var request = Request(url: "https://example.com/get") request.headers = [ @@ -62,8 +62,8 @@ class HTTPClientRequestTests: XCTestCase { } func testUnixScheme() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { var request = Request(url: "unix://%2Fexample%2Ffolder.sock/some_path") request.headers = ["custom-header": "custom-value"] @@ -93,8 +93,8 @@ class HTTPClientRequestTests: XCTestCase { } func testHTTPUnixScheme() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { var request = Request(url: "http+unix://%2Fexample%2Ffolder.sock/some_path") request.headers = ["custom-header": "custom-value"] @@ -124,8 +124,8 @@ class HTTPClientRequestTests: XCTestCase { } func testHTTPSUnixScheme() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { var request = Request(url: "https+unix://%2Fexample%2Ffolder.sock/some_path") request.headers = ["custom-header": "custom-value"] @@ -155,8 +155,8 @@ class HTTPClientRequestTests: XCTestCase { } func testGetWithoutBody() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { let request = Request(url: "https://example.com/get") var preparedRequest: PreparedRequest? @@ -185,8 +185,8 @@ class HTTPClientRequestTests: XCTestCase { } func testPostWithoutBody() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { var request = Request(url: "http://example.com/post") request.method = .POST @@ -220,8 +220,8 @@ class HTTPClientRequestTests: XCTestCase { } func testPostWithEmptyByteBuffer() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { var request = Request(url: "http://example.com/post") request.method = .POST @@ -256,8 +256,8 @@ class HTTPClientRequestTests: XCTestCase { } func testPostWithByteBuffer() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { var request = Request(url: "http://example.com/post") request.method = .POST @@ -291,8 +291,8 @@ class HTTPClientRequestTests: XCTestCase { } func testPostWithSequenceOfUnknownLength() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { var request = Request(url: "http://example.com/post") request.method = .POST @@ -327,8 +327,8 @@ class HTTPClientRequestTests: XCTestCase { } func testPostWithSequenceWithFixedLength() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { var request = Request(url: "http://example.com/post") request.method = .POST @@ -364,8 +364,8 @@ class HTTPClientRequestTests: XCTestCase { } func testPostWithRandomAccessCollection() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { var request = Request(url: "http://example.com/post") request.method = .POST @@ -400,8 +400,8 @@ class HTTPClientRequestTests: XCTestCase { } func testPostWithAsyncSequenceOfUnknownLength() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { var request = Request(url: "http://example.com/post") request.method = .POST @@ -441,8 +441,8 @@ class HTTPClientRequestTests: XCTestCase { } func testPostWithAsyncSequenceWithKnownLength() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { var request = Request(url: "http://example.com/post") request.method = .POST @@ -482,13 +482,13 @@ class HTTPClientRequestTests: XCTestCase { } } -#if compiler(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.2) && canImport(_Concurrency) private struct LengthMismatch: Error { var announcedLength: Int var actualLength: Int } -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) extension Optional where Wrapped == HTTPClientRequest.Body { /// Accumulates all data from `self` into a single `ByteBuffer` and checks that the user specified length matches /// the length of the accumulated data. @@ -549,7 +549,7 @@ extension Collection { } } -@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) struct AsyncSequenceFromSyncSequence: AsyncSequence { typealias Element = Wrapped.Element struct AsyncIterator: AsyncIteratorProtocol { @@ -566,7 +566,7 @@ struct AsyncSequenceFromSyncSequence: AsyncSequence { } } -@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) extension Sequence { /// Turns `self` into an `AsyncSequence` by wending each element of `self` asynchronously. func asAsyncSequence() -> AsyncSequenceFromSyncSequence { diff --git a/Tests/AsyncHTTPClientTests/Transaction+StateMachineTests.swift b/Tests/AsyncHTTPClientTests/Transaction+StateMachineTests.swift index 3237d19e8..ff1972330 100644 --- a/Tests/AsyncHTTPClientTests/Transaction+StateMachineTests.swift +++ b/Tests/AsyncHTTPClientTests/Transaction+StateMachineTests.swift @@ -20,8 +20,8 @@ import XCTest final class Transaction_StateMachineTests: XCTestCase { func testRequestWasQueuedAfterWillExecuteRequestWasCalled() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } let eventLoop = EmbeddedEventLoop() XCTAsyncTest { func workaround(_ continuation: CheckedContinuation) { @@ -50,8 +50,8 @@ final class Transaction_StateMachineTests: XCTestCase { } func testRequestBodyStreamWasPaused() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } let eventLoop = EmbeddedEventLoop() XCTAsyncTest { func workaround(_ continuation: CheckedContinuation) { @@ -73,8 +73,8 @@ final class Transaction_StateMachineTests: XCTestCase { } func testQueuedRequestGetsRemovedWhenDeadlineExceeded() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { func workaround(_ continuation: CheckedContinuation) { var state = Transaction.StateMachine(continuation) @@ -97,8 +97,8 @@ final class Transaction_StateMachineTests: XCTestCase { } func testScheduledRequestGetsRemovedWhenDeadlineExceeded() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } let eventLoop = EmbeddedEventLoop() XCTAsyncTest { func workaround(_ continuation: CheckedContinuation) { @@ -124,8 +124,8 @@ final class Transaction_StateMachineTests: XCTestCase { } func testRequestWithHeadReceivedGetNotCancelledWhenDeadlineExceeded() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } let eventLoop = EmbeddedEventLoop() XCTAsyncTest { func workaround(_ continuation: CheckedContinuation) { @@ -154,8 +154,8 @@ final class Transaction_StateMachineTests: XCTestCase { } } -#if compiler(>=5.5) && canImport(_Concurrency) -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +#if compiler(>=5.5.2) && canImport(_Concurrency) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) extension Transaction.StateMachine.StartExecutionAction: Equatable { public static func == (lhs: Self, rhs: Self) -> Bool { switch (lhs, rhs) { @@ -172,7 +172,7 @@ extension Transaction.StateMachine.StartExecutionAction: Equatable { } } -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) extension Transaction.StateMachine.ResumeProducingAction: Equatable { public static func == (lhs: Self, rhs: Self) -> Bool { switch (lhs, rhs) { @@ -188,7 +188,7 @@ extension Transaction.StateMachine.ResumeProducingAction: Equatable { } } -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) extension Transaction.StateMachine.NextWriteAction: Equatable { public static func == (lhs: Self, rhs: Self) -> Bool { switch (lhs, rhs) { diff --git a/Tests/AsyncHTTPClientTests/TransactionTests.swift b/Tests/AsyncHTTPClientTests/TransactionTests.swift index 9513605f7..8857253b6 100644 --- a/Tests/AsyncHTTPClientTests/TransactionTests.swift +++ b/Tests/AsyncHTTPClientTests/TransactionTests.swift @@ -21,15 +21,15 @@ import NIOHTTP1 import NIOPosix import XCTest -#if compiler(>=5.5) && canImport(_Concurrency) -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +#if compiler(>=5.5.2) && canImport(_Concurrency) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) typealias PreparedRequest = HTTPClientRequest.Prepared #endif final class TransactionTests: XCTestCase { func testCancelAsyncRequest() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { let embeddedEventLoop = EmbeddedEventLoop() defer { XCTAssertNoThrow(try embeddedEventLoop.syncShutdownGracefully()) } @@ -64,8 +64,8 @@ final class TransactionTests: XCTestCase { } func testResponseStreamingWorks() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { let embeddedEventLoop = EmbeddedEventLoop() defer { XCTAssertNoThrow(try embeddedEventLoop.syncShutdownGracefully()) } @@ -127,8 +127,8 @@ final class TransactionTests: XCTestCase { } func testIgnoringResponseBodyWorks() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { let embeddedEventLoop = EmbeddedEventLoop() defer { XCTAssertNoThrow(try embeddedEventLoop.syncShutdownGracefully()) } @@ -178,8 +178,8 @@ final class TransactionTests: XCTestCase { } func testWriteBackpressureWorks() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { let embeddedEventLoop = EmbeddedEventLoop() defer { XCTAssertNoThrow(try embeddedEventLoop.syncShutdownGracefully()) } @@ -252,8 +252,8 @@ final class TransactionTests: XCTestCase { } func testSimpleGetRequest() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1) let eventLoop = eventLoopGroup.next() @@ -310,8 +310,8 @@ final class TransactionTests: XCTestCase { } func testSimplePostRequest() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { let embeddedEventLoop = EmbeddedEventLoop() defer { XCTAssertNoThrow(try embeddedEventLoop.syncShutdownGracefully()) } @@ -350,8 +350,8 @@ final class TransactionTests: XCTestCase { } func testPostStreamFails() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { let embeddedEventLoop = EmbeddedEventLoop() defer { XCTAssertNoThrow(try embeddedEventLoop.syncShutdownGracefully()) } @@ -395,8 +395,8 @@ final class TransactionTests: XCTestCase { } func testResponseStreamFails() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { let embeddedEventLoop = EmbeddedEventLoop() defer { XCTAssertNoThrow(try embeddedEventLoop.syncShutdownGracefully()) } @@ -458,8 +458,8 @@ final class TransactionTests: XCTestCase { } func testBiDirectionalStreamingHTTP2() { - #if compiler(>=5.5) && canImport(_Concurrency) - guard #available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) else { return } + #if compiler(>=5.5.2) && canImport(_Concurrency) + guard #available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) else { return } XCTAsyncTest { let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1) let eventLoop = eventLoopGroup.next() @@ -533,12 +533,12 @@ final class TransactionTests: XCTestCase { } } -#if compiler(>=5.5) && canImport(_Concurrency) +#if compiler(>=5.5.2) && canImport(_Concurrency) // This needs a small explanation. If an iterator is a struct, it can't be used across multiple // tasks. Since we want to wait for things to happen in tests, we need to `async let`, which creates // implicit tasks. Therefore we need to wrap our iterator struct. -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) actor SharedIterator { private var iterator: Iterator @@ -553,7 +553,7 @@ actor SharedIterator { } } -@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) extension Transaction { fileprivate static func makeWithResultTask( request: PreparedRequest, diff --git a/Tests/AsyncHTTPClientTests/XCTest+AsyncAwait.swift b/Tests/AsyncHTTPClientTests/XCTest+AsyncAwait.swift index f26e11582..fbc429b10 100644 --- a/Tests/AsyncHTTPClientTests/XCTest+AsyncAwait.swift +++ b/Tests/AsyncHTTPClientTests/XCTest+AsyncAwait.swift @@ -26,11 +26,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#if compiler(>=5.5) +#if compiler(>=5.5.2) && canImport(_Concurrency) import XCTest extension XCTestCase { - @available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) + @available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) /// Cross-platform XCTest support for async-await tests. /// /// Currently the Linux implementation of XCTest doesn't have async-await support. @@ -61,7 +61,7 @@ extension XCTestCase { } } -@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) internal func XCTAssertThrowsError( _ expression: @autoclosure () async throws -> T, verify: (Error) -> Void = { _ in }, @@ -76,7 +76,7 @@ internal func XCTAssertThrowsError( } } -@available(macOS 12, iOS 15, tvOS 15, watchOS 8, *) +@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *) internal func XCTAssertNoThrowWithResult( _ expression: @autoclosure () async throws -> Result, file: StaticString = #file, @@ -90,4 +90,4 @@ internal func XCTAssertNoThrowWithResult( return nil } -#endif // compiler(>=5.5) +#endif