Skip to content
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
33 changes: 29 additions & 4 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ jobs:
name: Unit tests
uses: apple/swift-nio/.github/workflows/unit_tests.yml@main
with:
linux_5_10_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -warnings-as-errors"
linux_6_0_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -warnings-as-errors"
linux_6_1_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -warnings-as-errors"
linux_6_2_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -warnings-as-errors"
linux_nightly_next_arguments_override: "--explicit-target-dependency-import-check error"
Expand All @@ -27,8 +25,6 @@ jobs:
cxx-interop:
name: Cxx interop
uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main
with:
linux_5_9_enabled: false

static-sdk:
name: Static SDK
Expand All @@ -38,3 +34,32 @@ jobs:
release-builds:
name: Release builds
uses: apple/swift-nio/.github/workflows/release_builds.yml@main

construct-linkage-test-matrix:
name: Construct linkage matrix
runs-on: ubuntu-latest
outputs:
linkage-test-matrix: '${{ steps.generate-matrix.outputs.linkage-test-matrix }}'
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
persist-credentials: false
- id: generate-matrix
run: echo "linkage-test-matrix=$(curl -s https://raw.githubusercontent.com/apple/swift-nio/main/scripts/generate_matrix.sh | bash)" >> "$GITHUB_OUTPUT"
env:
MATRIX_LINUX_SETUP_COMMAND: apt-get update -y && apt-get install -yq jq && git config --global --add safe.directory /async-http-client
MATRIX_LINUX_COMMAND: ./scripts/run-linkage-test.sh
MATRIX_LINUX_5_10_ENABLED: false
MATRIX_LINUX_6_0_ENABLED: false
MATRIX_LINUX_6_1_ENABLED: false
MATRIX_LINUX_NIGHTLY_NEXT_ENABLED: false
MATRIX_LINUX_NIGHTLY_MAIN_ENABLED: false

linkage-test:
name: Linkage test
needs: construct-linkage-test-matrix
uses: apple/swift-nio/.github/workflows/swift_test_matrix.yml@main
with:
name: "Linkage test"
matrix_string: '${{ needs.construct-linkage-test-matrix.outputs.linkage-test-matrix }}'
11 changes: 8 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ let package = Package(
.library(name: "AsyncHTTPClient", targets: ["AsyncHTTPClient"])
],
dependencies: [
.package(url: "https://github.com/apple/swift-nio.git", from: "2.81.0"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.100.0"),
.package(url: "https://github.com/apple/swift-nio-ssl.git", from: "2.30.0"),
.package(url: "https://github.com/apple/swift-nio-http2.git", from: "1.36.0"),
.package(url: "https://github.com/apple/swift-nio-extras.git", from: "1.26.0"),
Expand All @@ -54,7 +54,8 @@ let package = Package(
.package(url: "https://github.com/apple/swift-atomics.git", from: "1.0.2"),
.package(url: "https://github.com/apple/swift-algorithms.git", from: "1.0.0"),
.package(url: "https://github.com/apple/swift-distributed-tracing.git", from: "1.3.0"),
.package(url: "https://github.com/apple/swift-configuration.git", from: "1.0.0"),
// Disable all traits to prevent linking Foundation
.package(url: "https://github.com/apple/swift-configuration.git", from: "1.0.0", traits: []),
.package(url: "https://github.com/apple/swift-service-context.git", from: "1.1.0"),
],
targets: [
Expand All @@ -78,7 +79,11 @@ let package = Package(
.product(name: "NIOSSL", package: "swift-nio-ssl"),
.product(name: "NIOHTTPCompression", package: "swift-nio-extras"),
.product(name: "NIOSOCKS", package: "swift-nio-extras"),
.product(name: "NIOTransportServices", package: "swift-nio-transport-services"),
.product(
name: "NIOTransportServices",
package: "swift-nio-transport-services",
condition: .when(platforms: [.macOS, .iOS, .tvOS, .watchOS, .macCatalyst, .visionOS])
),
.product(name: "Atomics", package: "swift-atomics"),
.product(name: "Algorithms", package: "swift-algorithms"),
.product(name: "Configuration", package: "swift-configuration"),
Expand Down
124 changes: 0 additions & 124 deletions Package@swift-6.0.swift

This file was deleted.

4 changes: 2 additions & 2 deletions Package@swift-6.1.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// swift-tools-version:6.0
// swift-tools-version:6.1
//===----------------------------------------------------------------------===//
//
// This source file is part of the AsyncHTTPClient open source project
Expand Down Expand Up @@ -35,7 +35,7 @@ let package = Package(
.library(name: "AsyncHTTPClient", targets: ["AsyncHTTPClient"])
],
dependencies: [
.package(url: "https://github.com/apple/swift-nio.git", from: "2.81.0"),
.package(url: "https://github.com/apple/swift-nio.git", from: "2.100.0"),
.package(url: "https://github.com/apple/swift-nio-ssl.git", from: "2.30.0"),
.package(url: "https://github.com/apple/swift-nio-http2.git", from: "1.36.0"),
.package(url: "https://github.com/apple/swift-nio-extras.git", from: "1.26.0"),
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ Please have a look at [SECURITY.md](SECURITY.md) for AsyncHTTPClient's security

## Supported Versions

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

AsyncHTTPClient | Minimum Swift Version
--------------------|----------------------
Expand All @@ -319,4 +319,5 @@ AsyncHTTPClient | Minimum Swift Version
`1.21.0 ..< 1.26.0` | 5.8
`1.26.0 ..< 1.27.0` | 5.9
`1.27.0 ..< 1.30.0` | 5.10
`1.30.0 ...` | 6.0
`1.30.0 ..< 1.34.0` | 6.0
`1.34.0 ...` | 6.1
5 changes: 5 additions & 0 deletions Sources/AsyncHTTPClient/AsyncAwait/HTTPClient+execute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ import NIOCore
import NIOHTTP1
import Tracing

#if canImport(FoundationEssentials)
import struct FoundationEssentials.URL
#else
import struct Foundation.URL
#endif

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension HTTPClient {
Expand Down Expand Up @@ -96,6 +100,7 @@ extension HTTPClient {
try HTTPClientRequest.Prepared(
currentRequest,
dnsOverride: configuration.dnsOverride,
localAddress: configuration.localAddress,
tracing: self.configuration.tracing
)
let response = try await {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ import NIOHTTP1
import NIOSSL
import ServiceContextModule

#if canImport(FoundationEssentials)
import struct FoundationEssentials.URL
#else
import struct Foundation.URL
#endif

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension HTTPClientRequest {
Expand Down Expand Up @@ -52,6 +56,7 @@ extension HTTPClientRequest.Prepared {
init(
_ request: HTTPClientRequest,
dnsOverride: [String: String] = [:],
localAddress: String? = nil,
tracing: HTTPClient.TracingConfiguration? = nil
) throws {
guard !request.url.isEmpty, let url = URL(string: request.url) else {
Expand All @@ -75,7 +80,12 @@ extension HTTPClientRequest.Prepared {

self.init(
url: url,
poolKey: .init(url: deconstructedURL, tlsConfiguration: request.tlsConfiguration, dnsOverride: dnsOverride),
poolKey: .init(
url: deconstructedURL,
tlsConfiguration: request.tlsConfiguration,
dnsOverride: dnsOverride,
localAddress: request.localAddress ?? localAddress
),
requestFramingMetadata: metadata,
head: .init(
version: .http1_1,
Expand Down Expand Up @@ -104,8 +114,8 @@ extension HTTPClientRequest.Prepared.Body {
case .byteBuffer(let byteBuffer):
self = .byteBuffer(byteBuffer)

case .httpClientRequestBody(let lenght, let requestBody):
self = .httpClientRequestBody(lenght, requestBody)
case .httpClientRequestBody(let length, let requestBody):
self = .httpClientRequestBody(length, requestBody)
}
}
}
Expand Down Expand Up @@ -147,6 +157,7 @@ extension HTTPClientRequest {
newRequest.method = method
newRequest.headers = headers
newRequest.body = body
newRequest.localAddress = self.localAddress
return newRequest
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
//
//===----------------------------------------------------------------------===//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension HTTPClientRequest {
Expand Down
21 changes: 14 additions & 7 deletions Sources/AsyncHTTPClient/AsyncAwait/HTTPClientRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ import NIOCore
import NIOHTTP1
import NIOSSL

#if canImport(HTTPAPIs)
import HTTPAPIs
#endif

@usableFromInline
let bagOfBytesToByteBufferConversionChunkSize = 1024 * 1024 * 4

Expand Down Expand Up @@ -57,12 +53,20 @@ public struct HTTPClientRequest: Sendable {
/// Request-specific TLS configuration, defaults to no request-specific TLS configuration.
public var tlsConfiguration: TLSConfiguration?

/// The local IP address to bind this request's connection to.
///
/// When set, overrides ``HTTPClient/Configuration/localAddress`` for this request.
/// The value should be an IP address string (e.g. `"192.168.1.10"` or `"::1"`).
/// Defaults to `nil` (use client configuration default).
public var localAddress: String?

public init(url: String) {
self.url = url
self.method = .GET
self.headers = .init()
self.body = .none
self.tlsConfiguration = nil
self.localAddress = nil
}
}

Expand Down Expand Up @@ -114,7 +118,12 @@ extension HTTPClientRequest {
@_spi(ExperimentalHTTPAPIsSupport)
public init(length: Int64?, startUpload: AsyncStream<RequestWriter>.Continuation) {
let length = length.map { RequestBodyLength.known($0) } ?? .unknown
self.init(.httpClientRequestBody(length: length, startUpload: RequestWriterContinuation(continuation: startUpload)))
self.init(
.httpClientRequestBody(
length: length,
startUpload: RequestWriterContinuation(continuation: startUpload)
)
)
}

@usableFromInline
Expand Down Expand Up @@ -431,10 +440,8 @@ extension HTTPClientRequest.Body: AsyncSequence {
return .init(storage: .byteBuffer(makeCompleteBody(AsyncIterator.allocator)))
case .byteBuffer(let byteBuffer):
return .init(storage: .byteBuffer(byteBuffer))
#if canImport(HTTPAPIs)
case .httpClientRequestBody:
fatalError("Unimplemented")
#endif
}
}
}
Expand Down
Loading
Loading