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
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ let package = Package(
dependencies: [
.package(
url: "https://github.com/apple/swift-http-api-proposal.git",
revision: "140b8c2aa773514e2464c15db8d94f4eca46d4a1"
revision: "d58fd6fa157e08bff44aa360ff83ebd424783392"
),
.package(
url: "https://github.com/apple/swift-async-algorithms.git",
from: "1.1.4",
revision: "3bd2de010e30f8d41481e6c7a49a7e7222a878cf",
traits: ["UnstableAsyncStreaming"]
),
.package(url: "https://github.com/apple/swift-http-types.git", from: "1.0.0"),
Expand Down
2 changes: 1 addition & 1 deletion Sources/Example/Example.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import NIOHTTPServer
import X509

@main
@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
struct Example {
static func main() async throws {
try await serve()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import NIOHTTP2
import SwiftASN1
public import X509

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension NIOHTTPServerConfiguration {
/// Initialize the server configuration from a config reader.
///
Expand Down Expand Up @@ -110,7 +110,7 @@ extension NIOHTTPServerConfiguration {
}
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension NIOHTTPServerConfiguration.BindTarget {
/// Initialize a bind target configuration from a config reader.
///
Expand All @@ -134,7 +134,7 @@ private enum HTTPVersionKind: String {
case http2
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension Set where Element == NIOHTTPServerConfiguration.HTTPVersion {
/// Initialize a supported HTTP versions configuration from a config reader.
///
Expand Down Expand Up @@ -171,7 +171,7 @@ extension Set where Element == NIOHTTPServerConfiguration.HTTPVersion {
}
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension NIOHTTPServerConfiguration.TransportSecurity {
/// Initialize a transport security configuration from a config reader.
///
Expand Down Expand Up @@ -242,7 +242,7 @@ extension NIOHTTPServerConfiguration.TransportSecurity {
}
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension NIOHTTPServerConfiguration.TransportSecurity.TLSCredentials {
/// Initialize TLS credentials (certificate chain and private key) from a config reader.
///
Expand Down Expand Up @@ -288,7 +288,7 @@ extension NIOHTTPServerConfiguration.TransportSecurity.TLSCredentials {
}
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension NIOHTTPServerConfiguration.TransportSecurity.MTLSTrustConfiguration {
/// Initialize an mTLS trust configuration from a config reader.
///
Expand Down Expand Up @@ -360,7 +360,7 @@ extension NIOHTTPServerConfiguration.TransportSecurity.MTLSTrustConfiguration {
}
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension NIOHTTPServerConfiguration.BackPressureStrategy {
/// Initialize the backpressure strategy configuration from a config reader.
///
Expand All @@ -387,7 +387,7 @@ extension NIOHTTPServerConfiguration.BackPressureStrategy {
}
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension NIOHTTPServerConfiguration.HTTP2 {
/// Initialize a HTTP/2 configuration from a config reader.
///
Expand Down Expand Up @@ -420,7 +420,7 @@ extension NIOHTTPServerConfiguration.HTTP2 {
}
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension NIOHTTPServerConfiguration.HTTP2.GracefulShutdownConfiguration {
/// Initialize a HTTP/2 graceful shutdown configuration from a config reader.
///
Expand All @@ -436,15 +436,15 @@ extension NIOHTTPServerConfiguration.HTTP2.GracefulShutdownConfiguration {
}
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension Set where Element == NIOHTTPServerConfiguration.HTTPVersion {
fileprivate enum HTTPVersionKind: String {
case http1_1
case http2
}
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension NIOHTTPServerConfiguration.TransportSecurity {
fileprivate enum TransportSecurityMode: String {
case plaintext
Expand All @@ -458,7 +458,7 @@ extension NIOHTTPServerConfiguration.TransportSecurity {
}
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension NIOHTTPServerConfiguration.TransportSecurity.MTLSTrustConfiguration {
/// The supported sources for trust roots.
fileprivate enum TrustRootsSource: String {
Expand All @@ -475,7 +475,7 @@ extension NIOHTTPServerConfiguration.TransportSecurity.MTLSTrustConfiguration {
}
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension CertificateVerificationMode {
fileprivate init(_ mode: NIOHTTPServerConfiguration.TransportSecurity.MTLSTrustConfiguration.VerificationMode) {
switch mode {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public import X509
///
/// This structure contains all the necessary configuration options for setting up
/// and running ``NIOHTTPServer``, including network binding and TLS settings.
@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
public struct NIOHTTPServerConfiguration: Sendable {
/// Specifies where the server should bind and listen for incoming connections.
///
Expand Down Expand Up @@ -303,7 +303,7 @@ public struct NIOHTTPServerConfiguration: Sendable {
///
/// Indicates whether certificate verification succeeded or failed, and provides associated metadata when verification
/// is successful.
@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
public enum CertificateVerificationResult: Sendable, Hashable {
/// Metadata resulting from successful certificate verification.
public struct VerificationMetadata: Sendable, Hashable {
Expand Down Expand Up @@ -367,7 +367,7 @@ public struct CertificateVerificationMode: Sendable {
}
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension NIOSSL.CertificateVerification {
/// Maps ``CertificateVerificationMode`` to the NIOSSL representation.
init(_ verificationMode: CertificateVerificationMode) {
Expand All @@ -380,7 +380,7 @@ extension NIOSSL.CertificateVerification {
}
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension NIOHTTPServerConfiguration {
/// Represents an HTTP version.
public struct HTTPVersion: Sendable, Hashable {
Expand Down Expand Up @@ -438,7 +438,7 @@ extension NIOHTTPServerConfiguration {
}
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension NIOAsyncSequenceProducerBackPressureStrategies.HighLowWatermark {
init(_ backpressureStrategy: NIOHTTPServerConfiguration.BackPressureStrategy) {
switch backpressureStrategy.backing {
Expand All @@ -448,7 +448,7 @@ extension NIOAsyncSequenceProducerBackPressureStrategies.HighLowWatermark {
}
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension Set where Element == NIOHTTPServerConfiguration.HTTPVersion {
/// The ALPN protocol identifiers to advertise during the TLS handshake, derived from the supported HTTP versions.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import NIOCore
import NIOSSL
public import X509

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension NIOHTTPServerConfiguration.TransportSecurity {
/// Configures how the server verifies client certificates during mTLS.
public struct MTLSTrustConfiguration: Sendable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import NIOCertificateReloading
import NIOSSL
import X509

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension NIOSSL.TLSConfiguration {
/// Creates a `NIOSSL.TLSConfiguration` from the server's TLS credentials and mTLS trust configuration.
static func makeServerConfiguration(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
public import NIOCertificateReloading
public import X509

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension NIOHTTPServerConfiguration.TransportSecurity {
/// Represents the server's TLS credentials: a certificate chain and its corresponding private key.
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/NIOHTTPServer/HTTPKeepAliveHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import NIOHTTPTypes
///
/// Informational (1xx) responses pass through unchanged and do not affect buffering
/// state.
@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
final class HTTPKeepAliveHandler: ChannelDuplexHandler {
typealias InboundIn = HTTPRequestPart
typealias InboundOut = HTTPRequestPart
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import Synchronization
/// and concluding with the HTTP trailer fields received at the end of the request. This type
/// follows the ``ConcludingAsyncReader`` pattern, which allows for asynchronous consumption of
/// a stream with a conclusive final element.
@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
public struct HTTPRequestConcludingAsyncReader: ConcludingAsyncReader, ~Copyable {
/// A reader for HTTP request body chunks that implements the ``AsyncReader`` protocol.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import Synchronization
///
/// This writer is designed to work with HTTP responses where the body is streamed in chunks
/// and potentially followed by trailer fields.
@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
public struct HTTPResponseConcludingAsyncWriter: ConcludingAsyncWriter, ~Copyable {
/// A writer for HTTP response body chunks that implements the ``AsyncWriter`` protocol.
///
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import NIOCore
import NIOSSL
public import X509

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension NIOHTTPServer {
/// Connection-specific information available during request handling.
///
Expand Down
2 changes: 1 addition & 1 deletion Sources/NIOHTTPServer/NIOHTTPServer+HTTP1_1.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import NIOHTTPTypes
import NIOHTTPTypesHTTP1
import NIOPosix

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension NIOHTTPServer {
/// Serves incoming plaintext HTTP/1.1 connections.
///
Expand Down
6 changes: 3 additions & 3 deletions Sources/NIOHTTPServer/NIOHTTPServer+ListeningAddress.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ enum ListeningAddressError: CustomStringConvertible, Error {
}
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension NIOHTTPServer {
func addressesBound(_ addresses: [NIOCore.SocketAddress?]) throws {
switch self.listeningAddressState.withLockedValue({ $0.addressesBound(addresses) }) {
Expand Down Expand Up @@ -63,7 +63,7 @@ extension NIOHTTPServer {
}
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension NIOHTTPServer {
enum State {
case idle(EventLoopPromise<[SocketAddress]>)
Expand Down Expand Up @@ -131,7 +131,7 @@ extension NIOHTTPServer {
}
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension NIOHTTPServer.SocketAddress {
fileprivate init(_ address: NIOCore.SocketAddress?) throws(ListeningAddressError) {
guard let address, let port = address.port else {
Expand Down
4 changes: 2 additions & 2 deletions Sources/NIOHTTPServer/NIOHTTPServer+SecureUpgrade.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import NIOSSL
import NIOTLS
import X509

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension NIOHTTPServer {
typealias NegotiatedChannel = NIONegotiatedHTTPVersion<
NIOAsyncChannel<HTTPRequestPart, HTTPResponsePart>,
Expand Down Expand Up @@ -354,7 +354,7 @@ extension NIOHTTPServer {
}
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension NIOHTTPServer {
func makeSSLServerHandler(
_ tlsConfiguration: TLSConfiguration,
Expand Down
4 changes: 2 additions & 2 deletions Sources/NIOHTTPServer/NIOHTTPServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ import X509
/// }
/// }
/// ```
@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
public struct NIOHTTPServer: HTTPServer {
public typealias RequestConcludingReader = HTTPRequestConcludingAsyncReader
public typealias ResponseConcludingWriter = HTTPResponseConcludingAsyncWriter
Expand Down Expand Up @@ -330,7 +330,7 @@ public struct NIOHTTPServer: HTTPServer {
}
}

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension NIOHTTP2Handler.Configuration {
init(httpServerHTTP2Configuration http2Config: NIOHTTPServerConfiguration.HTTP2) {
let clampedTargetWindowSize = Self.clampTargetWindowSize(http2Config.targetWindowSize)
Expand Down
2 changes: 1 addition & 1 deletion Sources/NIOHTTPServer/ServerChannel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import NIOCore
import NIOHTTPTypes

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension NIOHTTPServer {
/// Abstracts over the two types of server channels ``NIOHTTPServer`` can create: plaintext HTTP/1.1 and Secure
/// Upgrade.
Expand Down
2 changes: 1 addition & 1 deletion Sources/NIOHTTPServer/SocketAddress.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
//
//===----------------------------------------------------------------------===//

@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
extension NIOHTTPServer {
/// Represents an IPv4 address.
public struct IPv4: Hashable, Sendable {
Expand Down
10 changes: 5 additions & 5 deletions Tests/NIOHTTPServerTests/HTTPKeepAliveHandlerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ struct HTTPKeepAliveHandlerTests {
/// Verifies the happy case: when a client pipelines multiple HTTP/1.1 requests
/// on a single connection, all responses are returned in order and the connection
/// stays alive (no `Connection: close`).
@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
@Test("Pipelined requests on a single connection all succeed")
func testPipelinedRequests() async throws {
let server = NIOHTTPServer(
Expand Down Expand Up @@ -100,7 +100,7 @@ struct HTTPKeepAliveHandlerTests {
/// Verifies that when the handler writes a short response (head + end, no body)
/// before the request `.end` has arrived, the response head includes a
/// `Connection: close` header and the server closes the connection.
@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
@Test("Server sends head+end (no body) before request .end — Connection: close in header")
func testShortResponseBeforeRequestEnd() async throws {
let server = NIOHTTPServer(
Expand Down Expand Up @@ -181,7 +181,7 @@ struct HTTPKeepAliveHandlerTests {
/// the request `.end` has arrived; the client must receive that informational
/// response immediately (without waiting for request `.end`), and the connection
/// must remain alive after the final response.
@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
@Test("Informational (1xx) responses pass through without buffering or closing")
func testInformationalResponsePassesThrough() async throws {
let server = NIOHTTPServer(
Expand Down Expand Up @@ -294,7 +294,7 @@ struct HTTPKeepAliveHandlerTests {
/// everything until request `.end` arrives. Because the head is flushed before
/// request `.end` arrives, the response carries `Connection: close` and the
/// server closes the connection after writing response `.end`.
@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
@Test("Bidirectional streaming works — head is flushed (with Connection: close) when a body part is written")
func testBidirectionalStreamingOverHTTP1() async throws {
let server = NIOHTTPServer(
Expand Down Expand Up @@ -390,7 +390,7 @@ struct HTTPKeepAliveHandlerTests {
/// server reads the body chunk, the read cycle ends with the head still
/// buffered and request `.end` still missing — the keep-alive handler must add
/// `Connection: close`.
@available(macOS 26.2, iOS 26.2, watchOS 26.2, tvOS 26.2, visionOS 26.2, *)
@available(anyAppleOS 26.0, *)
@Test("Read cycle ends without request .end while head is buffered — Connection: close added")
func testReadCycleEndsWithoutRequestEnd_AddsConnectionClose() async throws {
let server = NIOHTTPServer(
Expand Down
Loading
Loading