Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

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 Package@swift-5.4.swift

This file was deleted.

2 changes: 1 addition & 1 deletion Package@swift-5.5.swift
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
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.

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

services:

runtime-setup:
image: async-http-client:22.04-5.7
build:
args:
base_image: "swift:5.7-jammy"

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

shell:
image: async-http-client:22.04-5.7