Skip to content

Raise minimum supported Swift version from 5.4 to 5.5 #630

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 0 additions & 73 deletions [email protected]

This file was deleted.

2 changes: 1 addition & 1 deletion [email protected]
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:5.4
// swift-tools-version:5.5
//===----------------------------------------------------------------------===//
//
// This source file is part of the AsyncHTTPClient open source project
Expand Down
41 changes: 26 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ httpClient.execute(request: request, deadline: .now() + .milliseconds(1))
```

### Streaming
When dealing with larger amount of data, it's critical to stream the response body instead of aggregating in-memory.
When dealing with larger amount of data, it's critical to stream the response body instead of aggregating in-memory.
The following example demonstrates how to count the number of bytes in a streaming response body:

#### Using Swift Concurrency
Expand All @@ -172,7 +172,7 @@ do {
for try await buffer in response.body {
// for this example, we are just interested in the size of the fragment
receivedBytes += buffer.readableBytes

if let expectedBytes = expectedBytes {
// if the body size is known, we calculate a progress indicator
let progress = Double(receivedBytes) / Double(expectedBytes)
Expand All @@ -181,9 +181,9 @@ do {
}
print("did receive \(receivedBytes) bytes")
} catch {
print("request failed:", error)
print("request failed:", error)
}
// it is important to shutdown the httpClient after all requests are done, even if one failed
// it is important to shutdown the httpClient after all requests are done, even if one failed
try await httpClient.shutdown()
```

Expand Down Expand Up @@ -211,17 +211,17 @@ class CountingDelegate: HTTPClientResponseDelegate {
}

func didReceiveHead(
task: HTTPClient.Task<Response>,
task: HTTPClient.Task<Response>,
_ head: HTTPResponseHead
) -> EventLoopFuture<Void> {
// this is executed when we receive HTTP response head part of the request
// (it contains response code and headers), called once in case backpressure
// this is executed when we receive HTTP response head part of the request
// (it contains response code and headers), called once in case backpressure
// is needed, all reads will be paused until returned future is resolved
return task.eventLoop.makeSucceededFuture(())
}

func didReceiveBodyPart(
task: HTTPClient.Task<Response>,
task: HTTPClient.Task<Response>,
_ buffer: ByteBuffer
) -> EventLoopFuture<Void> {
// this is executed when we receive parts of the response body, could be called zero or more times
Expand Down Expand Up @@ -283,8 +283,8 @@ Connecting to servers bound to socket paths is easy:
```swift
let httpClient = HTTPClient(eventLoopGroupProvider: .createNew)
httpClient.execute(
.GET,
socketPath: "/tmp/myServer.socket",
.GET,
socketPath: "/tmp/myServer.socket",
urlPath: "/path/to/resource"
).whenComplete (...)
```
Expand All @@ -293,21 +293,21 @@ Connecting over TLS to a unix domain socket path is possible as well:
```swift
let httpClient = HTTPClient(eventLoopGroupProvider: .createNew)
httpClient.execute(
.POST,
secureSocketPath: "/tmp/myServer.socket",
urlPath: "/path/to/resource",
.POST,
secureSocketPath: "/tmp/myServer.socket",
urlPath: "/path/to/resource",
body: .string("hello")
).whenComplete (...)
```

Direct URLs can easily be constructed to be executed in other scenarios:
```swift
let socketPathBasedURL = URL(
httpURLWithSocketPath: "/tmp/myServer.socket",
httpURLWithSocketPath: "/tmp/myServer.socket",
uri: "/path/to/resource"
)
let secureSocketPathBasedURL = URL(
httpsURLWithSocketPath: "/tmp/myServer.socket",
httpsURLWithSocketPath: "/tmp/myServer.socket",
uri: "/path/to/resource"
)
```
Expand All @@ -326,3 +326,14 @@ let client = HTTPClient(
## Security

Please have a look at [SECURITY.md](SECURITY.md) for AsyncHTTPClient's security process.

## Supported Versions

The most recent versions of AsyncHTTPClient support Swift 5.5 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
77 changes: 41 additions & 36 deletions Tests/LinuxMain.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,40 +25,45 @@ import XCTest
#if os(Linux) || os(FreeBSD)
@testable import AsyncHTTPClientTests

XCTMain([
testCase(AsyncAwaitEndToEndTests.allTests),
testCase(HTTP1ClientChannelHandlerTests.allTests),
testCase(HTTP1ConnectionStateMachineTests.allTests),
testCase(HTTP1ConnectionTests.allTests),
testCase(HTTP1ProxyConnectHandlerTests.allTests),
testCase(HTTP2ClientRequestHandlerTests.allTests),
testCase(HTTP2ClientTests.allTests),
testCase(HTTP2ConnectionTests.allTests),
testCase(HTTP2IdleHandlerTests.allTests),
testCase(HTTPClientCookieTests.allTests),
testCase(HTTPClientInternalTests.allTests),
testCase(HTTPClientNIOTSTests.allTests),
testCase(HTTPClientReproTests.allTests),
testCase(HTTPClientRequestTests.allTests),
testCase(HTTPClientSOCKSTests.allTests),
testCase(HTTPClientTests.allTests),
testCase(HTTPClientUncleanSSLConnectionShutdownTests.allTests),
testCase(HTTPConnectionPoolTests.allTests),
testCase(HTTPConnectionPool_FactoryTests.allTests),
testCase(HTTPConnectionPool_HTTP1ConnectionsTests.allTests),
testCase(HTTPConnectionPool_HTTP1StateMachineTests.allTests),
testCase(HTTPConnectionPool_HTTP2ConnectionsTests.allTests),
testCase(HTTPConnectionPool_HTTP2StateMachineTests.allTests),
testCase(HTTPConnectionPool_ManagerTests.allTests),
testCase(HTTPConnectionPool_RequestQueueTests.allTests),
testCase(HTTPRequestStateMachineTests.allTests),
testCase(LRUCacheTests.allTests),
testCase(RequestBagTests.allTests),
testCase(RequestValidationTests.allTests),
testCase(SOCKSEventsHandlerTests.allTests),
testCase(SSLContextCacheTests.allTests),
testCase(TLSEventsHandlerTests.allTests),
testCase(TransactionTests.allTests),
testCase(Transaction_StateMachineTests.allTests),
])
@main
struct LinuxMain {
static func main() {
XCTMain([
testCase(AsyncAwaitEndToEndTests.allTests),
testCase(HTTP1ClientChannelHandlerTests.allTests),
testCase(HTTP1ConnectionStateMachineTests.allTests),
testCase(HTTP1ConnectionTests.allTests),
testCase(HTTP1ProxyConnectHandlerTests.allTests),
testCase(HTTP2ClientRequestHandlerTests.allTests),
testCase(HTTP2ClientTests.allTests),
testCase(HTTP2ConnectionTests.allTests),
testCase(HTTP2IdleHandlerTests.allTests),
testCase(HTTPClientCookieTests.allTests),
testCase(HTTPClientInternalTests.allTests),
testCase(HTTPClientNIOTSTests.allTests),
testCase(HTTPClientReproTests.allTests),
testCase(HTTPClientRequestTests.allTests),
testCase(HTTPClientSOCKSTests.allTests),
testCase(HTTPClientTests.allTests),
testCase(HTTPClientUncleanSSLConnectionShutdownTests.allTests),
testCase(HTTPConnectionPoolTests.allTests),
testCase(HTTPConnectionPool_FactoryTests.allTests),
testCase(HTTPConnectionPool_HTTP1ConnectionsTests.allTests),
testCase(HTTPConnectionPool_HTTP1StateMachineTests.allTests),
testCase(HTTPConnectionPool_HTTP2ConnectionsTests.allTests),
testCase(HTTPConnectionPool_HTTP2StateMachineTests.allTests),
testCase(HTTPConnectionPool_ManagerTests.allTests),
testCase(HTTPConnectionPool_RequestQueueTests.allTests),
testCase(HTTPRequestStateMachineTests.allTests),
testCase(LRUCacheTests.allTests),
testCase(RequestBagTests.allTests),
testCase(RequestValidationTests.allTests),
testCase(SOCKSEventsHandlerTests.allTests),
testCase(SSLContextCacheTests.allTests),
testCase(TLSEventsHandlerTests.allTests),
testCase(TransactionTests.allTests),
testCase(Transaction_StateMachineTests.allTests),
])
}
}
#endif
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG swift_version=5.4
ARG ubuntu_version=bionic
ARG swift_version=5.7
ARG ubuntu_version=jammy
ARG base_image=swift:$swift_version-$ubuntu_version
FROM $base_image
# needed to do again after FROM due to docker limitation
Expand Down
19 changes: 0 additions & 19 deletions docker/docker-compose.1804.54.yaml

This file was deleted.

17 changes: 0 additions & 17 deletions docker/docker-compose.2004.57.yaml

This file was deleted.

18 changes: 18 additions & 0 deletions docker/docker-compose.2204.57.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
version: "3"

services:

runtime-setup:
image: async-http-client:22.04-5.7
build:
args:
ubuntu_version: "jammy"
swift_version: "5.7"

test:
image: async-http-client:22.04-5.7
environment: []
#- SANITIZER_ARG=--sanitize=thread

shell:
image: async-http-client:22.04-5.7
11 changes: 8 additions & 3 deletions scripts/generate_linux_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,10 @@ def createLinuxMain(testsDirectory, allTestSubDirectories, files)
file.write '@testable import ' + testSubDirectory + "\n"
end
file.write "\n"
file.write "XCTMain([\n"
file.write "@main\n"
file.write "struct LinuxMain {\n"
file.write " static func main() {\n"
file.write " XCTMain([\n"

testCases = []
for classes in files
Expand All @@ -109,9 +112,11 @@ def createLinuxMain(testsDirectory, allTestSubDirectories, files)
end

for testCase in testCases.sort { |x, y| x <=> y }
file.write ' testCase(' + testCase + ".allTests),\n"
file.write ' testCase(' + testCase + ".allTests),\n"
end
file.write "])\n"
file.write " ])\n"
file.write " }\n"
file.write "}\n"
file.write "#endif\n"
end
end
Expand Down