-
Notifications
You must be signed in to change notification settings - Fork 21
Abstract API: add server transport capability request option #146
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
base: main
Are you sure you want to change the base?
Changes from 3 commits
b49d7a5
8a363cf
dc10492
0fed93e
535c406
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This source file is part of the Swift HTTP API Proposal open source project | ||
| // | ||
| // Copyright (c) 2026 Apple Inc. and the Swift HTTP API Proposal project authors | ||
| // Licensed under Apache License v2.0 | ||
| // | ||
| // See LICENSE.txt for license information | ||
| // | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| public import NetworkTypes | ||
|
|
||
| @available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *) | ||
| extension HTTPClientCapability { | ||
| /// A protocol for HTTP request options that hint at the transports a | ||
| /// server is known to support. | ||
| /// | ||
| /// Providing server transport information allows the client to optimize | ||
| /// connection establishment. For example, if a server is known to support | ||
| /// QUIC, the client can attempt an HTTP/3 connection directly instead of | ||
| /// falling back to TCP-based negotiation. | ||
| public protocol ServerTransportCapabilityHint: RequestOptions { | ||
| /// The transports that the target server is known to support. | ||
| /// | ||
| /// An empty set indicates no prior knowledge of server capabilities, | ||
| /// and the client uses its default protocol negotiation behavior. | ||
| var serverSupportedTransports: Set<TransportVersion> { get set } | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| //===----------------------------------------------------------------------===// | ||
| // | ||
| // This source file is part of the Swift HTTP API Proposal open source project | ||
| // | ||
| // Copyright (c) 2026 Apple Inc. and the Swift HTTP API Proposal project authors | ||
| // Licensed under Apache License v2.0 | ||
| // | ||
| // See LICENSE.txt for license information | ||
| // | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| /// An enumeration that represents a transport protocol used to carry HTTP | ||
| /// traffic. | ||
| /// | ||
| /// ``TransportVersion`` provides type-safe access to supported transport | ||
| /// protocols, allowing clients and servers to communicate transport | ||
| /// capabilities. New transports may be added in future releases, so client | ||
| /// code must handle unknown cases. | ||
| @nonexhaustive | ||
| public enum TransportVersion: Sendable, Hashable { | ||
| /// Plaintext TCP transport. | ||
| case tcp | ||
|
|
||
| /// TCP with TLS transport. | ||
| case tcpWithTLS | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we don't need this case since whether the server supports TLS is already known to the user when they put http or https in the URL. |
||
|
|
||
| /// QUIC transport. | ||
| /// | ||
| /// QUIC is defined in RFC 9000 and is the transport used by HTTP/3 | ||
| /// (RFC 9114). | ||
| case quic | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,8 @@ public import NetworkTypes | |
| public struct URLSessionRequestOptions: | ||
| HTTPClientCapability.RedirectionHandler, | ||
| HTTPClientCapability.TLSSecurityHandler, | ||
| HTTPClientCapability.TLSVersionSelection | ||
| HTTPClientCapability.TLSVersionSelection, | ||
| HTTPClientCapability.ServerTransportCapabilityHint | ||
| { | ||
| public var redirectionHandler: (any HTTPClientRedirectionHandler)? = nil | ||
|
|
||
|
|
@@ -30,7 +31,7 @@ public struct URLSessionRequestOptions: | |
| public var maximumTLSVersion: TLSVersion = .v1_3 | ||
| public var allowsExpensiveNetworkAccess: Bool = true | ||
| public var allowsConstrainedNetworkAccess: Bool = true | ||
| public var assumesHTTP3Capable: Bool = false | ||
| public var serverSupportedTransports: Set<TransportVersion> = [] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should default it to
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated to |
||
| public var stallTimeout: Duration? = nil | ||
|
|
||
| public init() {} | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's name it HTTPTransportProtocol since this is specific to HTTP