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
2 changes: 1 addition & 1 deletion Examples/ProxyServer/ProxyServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ struct ProxyServer {
fatalError("Waiting for a concrete HTTP server implementation")
}

static func proxy(server: some HTTPServer, client: some HTTPClient & Sendable) async throws {
static func proxy(server: some HTTPServer, client: some HTTPClient) async throws {
try await server.serve { request, requestContext, serverRequestBodyAndTrailers, responseSender in
// We need to use a mutex here to move the requestBodyAndTrailers into the
// @Sendable restartable body
Expand Down
2 changes: 1 addition & 1 deletion Sources/HTTPAPIs/Client/HTTPClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
/// ``HTTPClient`` provides asynchronous request execution with streaming request
/// and response bodies.
@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
public protocol HTTPClient<RequestOptions>: ~Copyable {
public protocol HTTPClient<RequestOptions>: Sendable, ~Copyable {
associatedtype RequestOptions: HTTPClientCapability.RequestOptions

/// The type used to write request body data and trailers.
Expand Down
2 changes: 1 addition & 1 deletion Sources/HTTPClient/DefaultHTTPClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public struct HTTPConnectionPoolConfiguration: Hashable, Sendable {
/// connections across multiple requests. It supports HTTP/1.1, HTTP/2, and HTTP/3 protocols,
/// automatically handling connection management, protocol negotiation, and resource cleanup.
@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
public struct DefaultHTTPClient: HTTPClient, Sendable, ~Copyable {
public struct DefaultHTTPClient: HTTPClient, ~Copyable {
public struct RequestWriter: AsyncWriter, ~Copyable {
public mutating func write<Result, Failure>(
_ body: (inout OutputSpan<UInt8>) async throws(Failure) -> Result
Expand Down
2 changes: 1 addition & 1 deletion Sources/HTTPClient/URLSession/URLSessionHTTPClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import NetworkTypes
import Synchronization

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
final class URLSessionHTTPClient: HTTPClient, IdleTimerEntryProvider, Sendable {
final class URLSessionHTTPClient: HTTPClient, IdleTimerEntryProvider {
typealias RequestWriter = URLSessionRequestStreamBridge
typealias ResponseConcludingReader = URLSessionTaskDelegateBridge

Expand Down
38 changes: 19 additions & 19 deletions Sources/HTTPClientConformance/HTTPClientConformance.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import Foundation
#endif

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
public func runAllConformanceTests<Client: HTTPClient & Sendable & ~Copyable>(
public func runAllConformanceTests<Client: HTTPClient & ~Copyable>(
_ clientFactory: () async throws -> Client
) async throws where Client.RequestOptions: HTTPClientCapability.RedirectionHandler {
// Start the server that the conformance tests will interact with
Expand Down Expand Up @@ -57,7 +57,7 @@ public func runAllConformanceTests<Client: HTTPClient & Sendable & ~Copyable>(
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
func ok<Client: HTTPClient & Sendable & ~Copyable>(_ client: consuming Client) async throws {
func ok<Client: HTTPClient & ~Copyable>(_ client: consuming Client) async throws {
let methods = [HTTPRequest.Method.head, .get, .put, .post, .delete]
for method in methods {
let request = HTTPRequest(
Expand All @@ -80,7 +80,7 @@ func ok<Client: HTTPClient & Sendable & ~Copyable>(_ client: consuming Client) a
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
func emptyChunkedBody<Client: HTTPClient & Sendable & ~Copyable>(_ client: consuming Client) async throws {
func emptyChunkedBody<Client: HTTPClient & ~Copyable>(_ client: consuming Client) async throws {
let request = HTTPRequest(
method: .post,
scheme: "http",
Expand All @@ -106,7 +106,7 @@ func emptyChunkedBody<Client: HTTPClient & Sendable & ~Copyable>(_ client: consu
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
func echoString<Client: HTTPClient & Sendable & ~Copyable>(_ client: consuming Client) async throws {
func echoString<Client: HTTPClient & ~Copyable>(_ client: consuming Client) async throws {
let request = HTTPRequest(
method: .post,
scheme: "http",
Expand Down Expand Up @@ -134,7 +134,7 @@ func echoString<Client: HTTPClient & Sendable & ~Copyable>(_ client: consuming C
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
func gzip<Client: HTTPClient & Sendable & ~Copyable>(_ client: consuming Client) async throws {
func gzip<Client: HTTPClient & ~Copyable>(_ client: consuming Client) async throws {
let request = HTTPRequest(
method: .get,
scheme: "http",
Expand Down Expand Up @@ -163,7 +163,7 @@ func gzip<Client: HTTPClient & Sendable & ~Copyable>(_ client: consuming Client)
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
func deflate<Client: HTTPClient & Sendable & ~Copyable>(_ client: consuming Client) async throws {
func deflate<Client: HTTPClient & ~Copyable>(_ client: consuming Client) async throws {
let request = HTTPRequest(
method: .get,
scheme: "http",
Expand Down Expand Up @@ -192,7 +192,7 @@ func deflate<Client: HTTPClient & Sendable & ~Copyable>(_ client: consuming Clie
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
func brotli<Client: HTTPClient & Sendable & ~Copyable>(_ client: consuming Client) async throws {
func brotli<Client: HTTPClient & ~Copyable>(_ client: consuming Client) async throws {
let request = HTTPRequest(
method: .get,
scheme: "http",
Expand Down Expand Up @@ -221,7 +221,7 @@ func brotli<Client: HTTPClient & Sendable & ~Copyable>(_ client: consuming Clien
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
func identity<Client: HTTPClient & Sendable & ~Copyable>(_ client: consuming Client) async throws {
func identity<Client: HTTPClient & ~Copyable>(_ client: consuming Client) async throws {
let request = HTTPRequest(
method: .get,
scheme: "http",
Expand All @@ -242,7 +242,7 @@ func identity<Client: HTTPClient & Sendable & ~Copyable>(_ client: consuming Cli
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
func customHeader<Client: HTTPClient & Sendable & ~Copyable>(_ client: consuming Client) async throws {
func customHeader<Client: HTTPClient & ~Copyable>(_ client: consuming Client) async throws {
let request = HTTPRequest(
method: .post,
scheme: "http",
Expand Down Expand Up @@ -270,7 +270,7 @@ func customHeader<Client: HTTPClient & Sendable & ~Copyable>(_ client: consuming
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
func redirect308<Client: HTTPClient & Sendable & ~Copyable>(_ client: consuming Client) async throws
func redirect308<Client: HTTPClient & ~Copyable>(_ client: consuming Client) async throws
where Client.RequestOptions: HTTPClientCapability.RedirectionHandler {
let request = HTTPRequest(
method: .get,
Expand Down Expand Up @@ -302,7 +302,7 @@ where Client.RequestOptions: HTTPClientCapability.RedirectionHandler {
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
func redirect301<Client: HTTPClient & Sendable & ~Copyable>(_ client: consuming Client) async throws
func redirect301<Client: HTTPClient & ~Copyable>(_ client: consuming Client) async throws
where Client.RequestOptions: HTTPClientCapability.RedirectionHandler {
let request = HTTPRequest(
method: .get,
Expand Down Expand Up @@ -334,7 +334,7 @@ where Client.RequestOptions: HTTPClientCapability.RedirectionHandler {
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
func notFound<Client: HTTPClient & Sendable & ~Copyable>(_ client: consuming Client) async throws {
func notFound<Client: HTTPClient & ~Copyable>(_ client: consuming Client) async throws {
let request = HTTPRequest(
method: .get,
scheme: "http",
Expand All @@ -354,7 +354,7 @@ func notFound<Client: HTTPClient & Sendable & ~Copyable>(_ client: consuming Cli
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
func statusOutOfRangeButValid<Client: HTTPClient & Sendable & ~Copyable>(_ client: consuming Client) async throws {
func statusOutOfRangeButValid<Client: HTTPClient & ~Copyable>(_ client: consuming Client) async throws {
let request = HTTPRequest(
method: .get,
scheme: "http",
Expand All @@ -374,7 +374,7 @@ func statusOutOfRangeButValid<Client: HTTPClient & Sendable & ~Copyable>(_ clien
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
func stressTest<Client: HTTPClient & Sendable & ~Copyable>(_ clientFactory: () async throws -> Client) async throws {
func stressTest<Client: HTTPClient & ~Copyable>(_ clientFactory: () async throws -> Client) async throws {
let request = HTTPRequest(
method: .get,
scheme: "http",
Expand Down Expand Up @@ -408,7 +408,7 @@ func stressTest<Client: HTTPClient & Sendable & ~Copyable>(_ clientFactory: () a
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
func echoInterleave<Client: HTTPClient & Sendable & ~Copyable>(_ client: consuming Client) async throws {
func echoInterleave<Client: HTTPClient & ~Copyable>(_ client: consuming Client) async throws {
let request = HTTPRequest(
method: .post,
scheme: "http",
Expand Down Expand Up @@ -455,7 +455,7 @@ func echoInterleave<Client: HTTPClient & Sendable & ~Copyable>(_ client: consumi
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
func cancelPreHeaders<Client: HTTPClient & Sendable & ~Copyable>(_ clientFactory: () async throws -> Client) async throws {
func cancelPreHeaders<Client: HTTPClient & ~Copyable>(_ clientFactory: () async throws -> Client) async throws {
try await withThrowingTaskGroup { group in
let client = try await clientFactory()

Expand Down Expand Up @@ -493,7 +493,7 @@ func cancelPreHeaders<Client: HTTPClient & Sendable & ~Copyable>(_ clientFactory
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
func cancelPreBody<Client: HTTPClient & Sendable & ~Copyable>(_ clientFactory: () async throws -> Client) async throws {
func cancelPreBody<Client: HTTPClient & ~Copyable>(_ clientFactory: () async throws -> Client) async throws {
try await withThrowingTaskGroup { group in
// Used by the task to notify when the task group should be cancelled
let (stream, continuation) = AsyncStream<Void>.makeStream()
Expand Down Expand Up @@ -544,7 +544,7 @@ func cancelPreBody<Client: HTTPClient & Sendable & ~Copyable>(_ clientFactory: (
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
func getConvenience<Client: HTTPClient & Sendable & ~Copyable>(_ client: consuming Client) async throws {
func getConvenience<Client: HTTPClient & ~Copyable>(_ client: consuming Client) async throws {
let (response, data) = try await client.get(
url: URL(string: "http://127.0.0.1:12345/request")!,
collectUpTo: .max
Expand All @@ -557,7 +557,7 @@ func getConvenience<Client: HTTPClient & Sendable & ~Copyable>(_ client: consumi
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
func postConvenience<Client: HTTPClient & Sendable & ~Copyable>(_ client: consuming Client) async throws {
func postConvenience<Client: HTTPClient & ~Copyable>(_ client: consuming Client) async throws {
let (response, data) = try await client.post(
url: URL(string: "http://127.0.0.1:12345/request")!,
bodyData: Data("Hello World".utf8),
Expand Down
2 changes: 1 addition & 1 deletion Tests/HTTPAPIsTests/Helpers/HTTPClientAndServerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import Testing
///
/// This type hooks up a client to a server in-process.
@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
final class TestClientAndServer: HTTPClient, HTTPServer, Sendable {
final class TestClientAndServer: HTTPClient, HTTPServer {
struct RequestOptions: HTTPClientCapability.RequestOptions {
init() {}
}
Expand Down
Loading