Skip to content

Commit

Permalink
Drop Swift 5.5 (#686)
Browse files Browse the repository at this point in the history
  • Loading branch information
dnadoba authored Apr 14, 2023
1 parent 333e60c commit d62c475
Show file tree
Hide file tree
Showing 54 changed files with 5 additions and 2,332 deletions.
75 changes: 0 additions & 75 deletions [email protected]

This file was deleted.

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,12 @@ Please have a look at [SECURITY.md](SECURITY.md) for AsyncHTTPClient's security

## Supported Versions

The most recent versions of AsyncHTTPClient support Swift 5.5.2 and newer. The minimum Swift version supported by AsyncHTTPClient releases are detailed below:
The most recent versions of AsyncHTTPClient support Swift 5.6 and newer. The minimum Swift version supported by AsyncHTTPClient releases are detailed below:

AsyncHTTPClient | Minimum Swift Version
--------------------|----------------------
`1.0.0 ..< 1.5.0` | 5.0
`1.5.0 ..< 1.10.0` | 5.2
`1.10.0 ..< 1.13.0` | 5.4
`1.13.0 ...` | 5.5.2
`1.13.0 ..< 1.18.0` | 5.5.2
`1.18.0 ...` | 5.6
110 changes: 0 additions & 110 deletions Sources/AsyncHTTPClient/AsyncAwait/HTTPClientRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ extension HTTPClientRequest.Body {
self.init(.byteBuffer(byteBuffer))
}

#if swift(>=5.6)
/// Create an ``HTTPClientRequest/Body-swift.struct`` from a `RandomAccessCollection` of bytes.
///
/// This construction will flatten the bytes into a `ByteBuffer`. As a result, the peak memory
Expand All @@ -106,21 +105,6 @@ extension HTTPClientRequest.Body {
) -> Self where Bytes.Element == UInt8 {
Self._bytes(bytes)
}
#else
/// Create an ``HTTPClientRequest/Body-swift.struct`` from a `RandomAccessCollection` of bytes.
///
/// This construction will flatten the bytes into a `ByteBuffer`. As a result, the peak memory
/// usage of this construction will be double the size of the original collection. The construction
/// of the `ByteBuffer` will be delayed until it's needed.
///
/// - parameter bytes: The bytes of the request body.
@inlinable
public static func bytes<Bytes: RandomAccessCollection>(
_ bytes: Bytes
) -> Self where Bytes.Element == UInt8 {
Self._bytes(bytes)
}
#endif

@inlinable
static func _bytes<Bytes: RandomAccessCollection>(
Expand All @@ -139,7 +123,6 @@ extension HTTPClientRequest.Body {
})
}

#if swift(>=5.6)
/// Create an ``HTTPClientRequest/Body-swift.struct`` from a `Sequence` of bytes.
///
/// This construction will flatten the bytes into a `ByteBuffer`. As a result, the peak memory
Expand All @@ -165,32 +148,6 @@ extension HTTPClientRequest.Body {
) -> Self where Bytes.Element == UInt8 {
Self._bytes(bytes, length: length)
}
#else
/// Create an ``HTTPClientRequest/Body-swift.struct`` from a `Sequence` of bytes.
///
/// This construction will flatten the bytes into a `ByteBuffer`. As a result, the peak memory
/// usage of this construction will be double the size of the original collection. The construction
/// of the `ByteBuffer` will be delayed until it's needed.
///
/// Unlike ``bytes(_:)-1uns7``, this construction does not assume that the body can be replayed. As a result,
/// if a redirect is encountered that would need us to replay the request body, the redirect will instead
/// not be followed. Prefer ``bytes(_:)-1uns7`` wherever possible.
///
/// Caution should be taken with this method to ensure that the `length` is correct. Incorrect lengths
/// will cause unnecessary runtime failures. Setting `length` to ``Length/unknown`` will trigger the upload
/// to use `chunked` `Transfer-Encoding`, while using ``Length/known(_:)`` will use `Content-Length`.
///
/// - parameters:
/// - bytes: The bytes of the request body.
/// - length: The length of the request body.
@inlinable
public static func bytes<Bytes: Sequence>(
_ bytes: Bytes,
length: Length
) -> Self where Bytes.Element == UInt8 {
Self._bytes(bytes, length: length)
}
#endif

@inlinable
static func _bytes<Bytes: Sequence>(
Expand All @@ -210,7 +167,6 @@ extension HTTPClientRequest.Body {
})
}

#if swift(>=5.6)
/// Create an ``HTTPClientRequest/Body-swift.struct`` from a `Collection` of bytes.
///
/// This construction will flatten the bytes into a `ByteBuffer`. As a result, the peak memory
Expand All @@ -232,28 +188,6 @@ extension HTTPClientRequest.Body {
) -> Self where Bytes.Element == UInt8 {
Self._bytes(bytes, length: length)
}
#else
/// Create an ``HTTPClientRequest/Body-swift.struct`` from a `Collection` of bytes.
///
/// This construction will flatten the bytes into a `ByteBuffer`. As a result, the peak memory
/// usage of this construction will be double the size of the original collection. The construction
/// of the `ByteBuffer` will be delayed until it's needed.
///
/// Caution should be taken with this method to ensure that the `length` is correct. Incorrect lengths
/// will cause unnecessary runtime failures. Setting `length` to ``Length/unknown`` will trigger the upload
/// to use `chunked` `Transfer-Encoding`, while using ``Length/known(_:)`` will use `Content-Length`.
///
/// - parameters:
/// - bytes: The bytes of the request body.
/// - length: The length of the request body.
@inlinable
public static func bytes<Bytes: Collection>(
_ bytes: Bytes,
length: Length
) -> Self where Bytes.Element == UInt8 {
Self._bytes(bytes, length: length)
}
#endif

@inlinable
static func _bytes<Bytes: Collection>(
Expand All @@ -273,7 +207,6 @@ extension HTTPClientRequest.Body {
})
}

#if swift(>=5.6)
/// Create an ``HTTPClientRequest/Body-swift.struct`` from an `AsyncSequence` of `ByteBuffer`s.
///
/// This construction will stream the upload one `ByteBuffer` at a time.
Expand All @@ -293,26 +226,6 @@ extension HTTPClientRequest.Body {
) -> Self where SequenceOfBytes.Element == ByteBuffer {
Self._stream(sequenceOfBytes, length: length)
}
#else
/// Create an ``HTTPClientRequest/Body-swift.struct`` from an `AsyncSequence` of `ByteBuffer`s.
///
/// This construction will stream the upload one `ByteBuffer` at a time.
///
/// Caution should be taken with this method to ensure that the `length` is correct. Incorrect lengths
/// will cause unnecessary runtime failures. Setting `length` to ``Length/unknown`` will trigger the upload
/// to use `chunked` `Transfer-Encoding`, while using ``Length/known(_:)`` will use `Content-Length`.
///
/// - parameters:
/// - sequenceOfBytes: The bytes of the request body.
/// - length: The length of the request body.
@inlinable
public static func stream<SequenceOfBytes: AsyncSequence>(
_ sequenceOfBytes: SequenceOfBytes,
length: Length
) -> Self where SequenceOfBytes.Element == ByteBuffer {
Self._stream(sequenceOfBytes, length: length)
}
#endif

@inlinable
static func _stream<SequenceOfBytes: AsyncSequence>(
Expand All @@ -328,7 +241,6 @@ extension HTTPClientRequest.Body {
return body
}

#if swift(>=5.6)
/// Create an ``HTTPClientRequest/Body-swift.struct`` from an `AsyncSequence` of bytes.
///
/// This construction will consume 1kB chunks from the `Bytes` and send them at once. This optimizes for
Expand All @@ -350,28 +262,6 @@ extension HTTPClientRequest.Body {
) -> Self where Bytes.Element == UInt8 {
Self._stream(bytes, length: length)
}
#else
/// Create an ``HTTPClientRequest/Body-swift.struct`` from an `AsyncSequence` of bytes.
///
/// This construction will consume 1kB chunks from the `Bytes` and send them at once. This optimizes for
/// `AsyncSequence`s where larger chunks are buffered up and available without actually suspending, such
/// as those provided by `FileHandle`.
///
/// Caution should be taken with this method to ensure that the `length` is correct. Incorrect lengths
/// will cause unnecessary runtime failures. Setting `length` to ``Length/unknown`` will trigger the upload
/// to use `chunked` `Transfer-Encoding`, while using ``Length/known(_:)`` will use `Content-Length`.
///
/// - parameters:
/// - bytes: The bytes of the request body.
/// - length: The length of the request body.
@inlinable
public static func stream<Bytes: AsyncSequence>(
_ bytes: Bytes,
length: Length
) -> Self where Bytes.Element == UInt8 {
Self._stream(bytes, length: length)
}
#endif

@inlinable
static func _stream<Bytes: AsyncSequence>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -433,10 +433,8 @@ final class HTTP1ClientChannelHandler: ChannelDuplexHandler {
}
}

#if swift(>=5.6)
@available(*, unavailable)
extension HTTP1ClientChannelHandler: Sendable {}
#endif

extension HTTP1ClientChannelHandler: HTTPRequestExecutor {
func writeRequestBodyPart(_ data: IOData, request: HTTPExecutableRequest, promise: EventLoopPromise<Void>?) {
Expand Down
6 changes: 0 additions & 6 deletions Sources/AsyncHTTPClient/Docs.docc/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ This library provides the following:
- Automatic HTTP/2 over HTTPS (since version 1.7.0)
- Cookie parsing (but not storage)

---

**NOTE**: You will need [Xcode 13.2](https://apps.apple.com/gb/app/xcode/id497799835?mt=12) or [Swift 5.5.2](https://swift.org/download/#swift-552) to try out `AsyncHTTPClient`s new async/await APIs.

---

### Getting Started

#### Adding the dependency
Expand Down
18 changes: 0 additions & 18 deletions Sources/AsyncHTTPClient/HTTPClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,6 @@ public class HTTPClient {
}
}

#if swift(>=5.6)
/// Shuts down the client and event loop gracefully.
///
/// This function is clearly an outlier in that it uses a completion
Expand All @@ -213,17 +212,6 @@ public class HTTPClient {
) {
self.shutdown(requiresCleanClose: false, queue: queue, callback)
}
#else
/// Shuts down the client and event loop gracefully.
///
/// This function is clearly an outlier in that it uses a completion
/// callback instead of an EventLoopFuture. The reason for that is that NIO's EventLoopFutures will call back on an event loop.
/// The virtue of this function is to shut the event loop down. To work around that we call back on a DispatchQueue
/// instead.
public func shutdown(queue: DispatchQueue = .global(), _ callback: @escaping (Error?) -> Void) {
self.shutdown(requiresCleanClose: false, queue: queue, callback)
}
#endif

/// Shuts down the ``HTTPClient`` and releases its resources.
///
Expand Down Expand Up @@ -917,11 +905,7 @@ public class HTTPClient {
case enabled(limit: NIOHTTPDecompression.DecompressionLimit)
}

#if swift(>=5.6)
typealias ShutdownCallback = @Sendable (Error?) -> Void
#else
typealias ShutdownCallback = (Error?) -> Void
#endif

enum State {
case upAndRunning
Expand All @@ -934,10 +918,8 @@ public class HTTPClient {
extension HTTPClient.Configuration: Sendable {}
#endif

#if swift(>=5.6)
extension HTTPClient.EventLoopGroupProvider: Sendable {}
extension HTTPClient.EventLoopPreference: Sendable {}
#endif

// HTTPClient is thread-safe because its shared mutable state is protected through a lock
extension HTTPClient: @unchecked Sendable {}
Expand Down
Loading

0 comments on commit d62c475

Please sign in to comment.