From 7835c470317f9dbcae374ffd28482abe8ec45628 Mon Sep 17 00:00:00 2001 From: Gus Cairo Date: Wed, 14 Jan 2026 15:30:14 +0000 Subject: [PATCH 1/9] Format YAML --- .github/workflows/main.yml | 52 +++++++++---------- .github/workflows/pull_request.yml | 80 +++++++++++++++--------------- 2 files changed, 66 insertions(+), 66 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 30f0d50..c05bb52 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,33 +4,33 @@ permissions: contents: read on: - push: - branches: [main] - schedule: - - cron: "0 8,20 * * *" + push: + branches: [main] + schedule: + - cron: "0 8,20 * * *" jobs: - unit-tests: - name: Unit tests - uses: apple/swift-nio/.github/workflows/unit_tests.yml@main - with: - linux_5_10_enabled: false - linux_6_0_enabled: false - linux_6_1_enabled: false - # linux_6_1_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" - linux_6_2_enabled: false - # linux_6_2_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" - linux_nightly_next_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" - linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" + unit-tests: + name: Unit tests + uses: apple/swift-nio/.github/workflows/unit_tests.yml@main + with: + linux_5_10_enabled: false + linux_6_0_enabled: false + linux_6_1_enabled: false + # linux_6_1_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" + linux_6_2_enabled: false + # linux_6_2_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" + linux_nightly_next_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" + linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error -Xswiftc -require-explicit-sendable" - static-sdk: - name: Static SDK - uses: apple/swift-nio/.github/workflows/static_sdk.yml@main + static-sdk: + name: Static SDK + uses: apple/swift-nio/.github/workflows/static_sdk.yml@main - release-builds: - name: Release builds - uses: apple/swift-nio/.github/workflows/release_builds.yml@main - with: - linux_5_10_enabled: false - linux_6_0_enabled: false - linux_6_1_enabled: false + release-builds: + name: Release builds + uses: apple/swift-nio/.github/workflows/release_builds.yml@main + with: + linux_5_10_enabled: false + linux_6_0_enabled: false + linux_6_1_enabled: false diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 9884262..1e5cc15 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -4,49 +4,49 @@ permissions: contents: read on: - pull_request: - types: [opened, reopened, synchronize] + pull_request: + types: [opened, reopened, synchronize] jobs: - soundness: - name: Soundness - uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main - with: - api_breakage_check_container_image: "swift:6.2-noble" - format_check_container_image: "swift:6.2-noble" - license_header_check_project_name: "Swift HTTP Server" + soundness: + name: Soundness + uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main + with: + api_breakage_check_container_image: "swift:6.2-noble" + format_check_container_image: "swift:6.2-noble" + license_header_check_project_name: "Swift HTTP Server" - unit-tests: - name: Unit tests - uses: apple/swift-nio/.github/workflows/unit_tests.yml@main - with: - linux_5_10_enabled: false - linux_6_0_enabled: false - linux_6_1_enabled: false - # linux_6_1_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error" - linux_6_2_enabled: true - linux_6_2_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error" - linux_nightly_next_arguments_override: "--explicit-target-dependency-import-check error" - linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error" + unit-tests: + name: Unit tests + uses: apple/swift-nio/.github/workflows/unit_tests.yml@main + with: + linux_5_10_enabled: false + linux_6_0_enabled: false + linux_6_1_enabled: false + # linux_6_1_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error" + linux_6_2_enabled: true + linux_6_2_arguments_override: "-Xswiftc -warnings-as-errors --explicit-target-dependency-import-check error" + linux_nightly_next_arguments_override: "--explicit-target-dependency-import-check error" + linux_nightly_main_arguments_override: "--explicit-target-dependency-import-check error" - cxx-interop: - name: Cxx interop - uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main - with: - linux_5_10_enabled: false - linux_6_0_enabled: false - linux_6_1_enabled: false - linux_6_2_enabled: true + cxx-interop: + name: Cxx interop + uses: apple/swift-nio/.github/workflows/cxx_interop.yml@main + with: + linux_5_10_enabled: false + linux_6_0_enabled: false + linux_6_1_enabled: false + linux_6_2_enabled: true - static-sdk: - name: Static SDK - uses: apple/swift-nio/.github/workflows/static_sdk.yml@main + static-sdk: + name: Static SDK + uses: apple/swift-nio/.github/workflows/static_sdk.yml@main - release-builds: - name: Release builds - uses: apple/swift-nio/.github/workflows/release_builds.yml@main - with: - linux_5_10_enabled: false - linux_6_0_enabled: false - linux_6_1_enabled: false - linux_6_2_enabled: true + release-builds: + name: Release builds + uses: apple/swift-nio/.github/workflows/release_builds.yml@main + with: + linux_5_10_enabled: false + linux_6_0_enabled: false + linux_6_1_enabled: false + linux_6_2_enabled: true From b38a991ea41c38ac5e8d62cd006bffd2ee996288 Mon Sep 17 00:00:00 2001 From: Gus Cairo Date: Wed, 14 Jan 2026 15:30:22 +0000 Subject: [PATCH 2/9] Add missing license headers --- Sources/AsyncStreaming/EitherError.swift | 5 ++--- .../Internal/InlineArray+convenience.swift | 5 ++--- .../Internal/Optional+SendingTake.swift | 5 ++--- .../AsyncStreaming/Reader/Array+AsyncReader.swift | 5 ++--- .../AsyncStreaming/Reader/AsyncReader+collect.swift | 5 ++--- .../AsyncStreaming/Reader/AsyncReader+forEach.swift | 5 ++--- Sources/AsyncStreaming/Reader/AsyncReader+map.swift | 5 ++--- Sources/AsyncStreaming/Reader/AsyncReader.swift | 5 ++--- .../Reader/ConcludingAsyncReader+collect.swift | 5 ++--- .../Reader/ConcludingAsyncReader.swift | 5 ++--- .../Writer/AsyncWriter+AsyncReader.swift | 5 ++--- Sources/AsyncStreaming/Writer/AsyncWriter.swift | 5 ++--- .../Writer/ConcludingAsyncWriter.swift | 5 ++--- .../Writer/RigidArray+AsyncWriter.swift | 5 ++--- Sources/HTTPServer/HTTPRequestContext.swift | 13 +++++++++++++ .../NIOHTTPServer+ConnectionContext.swift | 13 +++++++++++++ .../HTTPServer/RequestResponseMiddlewareBox.swift | 13 +++++++++++++ Sources/Middleware/ChainedMiddleware.swift | 13 +++++++++++++ Sources/Middleware/Middleware.swift | 13 +++++++++++++ Sources/Middleware/MiddlewareBuilder.swift | 13 +++++++++++++ Sources/Middleware/MiddlewareChain.swift | 13 +++++++++++++ .../HTTPRequestConcludingAsyncReaderTests.swift | 13 +++++++++++++ .../HTTPResponseConcludingAsyncWriterTests.swift | 13 +++++++++++++ Tests/HTTPServerTests/HTTPResponseSenderTests.swift | 13 +++++++++++++ Tests/HTTPServerTests/HTTPServerTests.swift | 13 +++++++++++++ Tests/HTTPServerTests/NIOHTTPServerTests.swift | 13 +++++++++++++ Tests/HTTPServerTests/Utilities/TestError.swift | 13 +++++++++++++ 27 files changed, 197 insertions(+), 42 deletions(-) diff --git a/Sources/AsyncStreaming/EitherError.swift b/Sources/AsyncStreaming/EitherError.swift index 69d2138..593e17f 100644 --- a/Sources/AsyncStreaming/EitherError.swift +++ b/Sources/AsyncStreaming/EitherError.swift @@ -1,12 +1,11 @@ //===----------------------------------------------------------------------===// // -// This source file is part of the Swift HTTP API Proposal open source project +// This source file is part of the Swift HTTP Server open source project // -// Copyright (c) 2025 Apple Inc. and the Swift HTTP API Proposal project authors +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of Swift HTTP API Proposal project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/AsyncStreaming/Internal/InlineArray+convenience.swift b/Sources/AsyncStreaming/Internal/InlineArray+convenience.swift index 30e66c4..62a9b83 100644 --- a/Sources/AsyncStreaming/Internal/InlineArray+convenience.swift +++ b/Sources/AsyncStreaming/Internal/InlineArray+convenience.swift @@ -1,12 +1,11 @@ //===----------------------------------------------------------------------===// // -// This source file is part of the Swift HTTP API Proposal open source project +// This source file is part of the Swift HTTP Server open source project // -// Copyright (c) 2025 Apple Inc. and the Swift HTTP API Proposal project authors +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of Swift HTTP API Proposal project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/AsyncStreaming/Internal/Optional+SendingTake.swift b/Sources/AsyncStreaming/Internal/Optional+SendingTake.swift index 604d0a2..570a846 100644 --- a/Sources/AsyncStreaming/Internal/Optional+SendingTake.swift +++ b/Sources/AsyncStreaming/Internal/Optional+SendingTake.swift @@ -1,12 +1,11 @@ //===----------------------------------------------------------------------===// // -// This source file is part of the Swift HTTP API Proposal open source project +// This source file is part of the Swift HTTP Server open source project // -// Copyright (c) 2025 Apple Inc. and the Swift HTTP API Proposal project authors +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of Swift HTTP API Proposal project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/AsyncStreaming/Reader/Array+AsyncReader.swift b/Sources/AsyncStreaming/Reader/Array+AsyncReader.swift index 826e86b..259b0c6 100644 --- a/Sources/AsyncStreaming/Reader/Array+AsyncReader.swift +++ b/Sources/AsyncStreaming/Reader/Array+AsyncReader.swift @@ -1,12 +1,11 @@ //===----------------------------------------------------------------------===// // -// This source file is part of the Swift HTTP API Proposal open source project +// This source file is part of the Swift HTTP Server open source project // -// Copyright (c) 2025 Apple Inc. and the Swift HTTP API Proposal project authors +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of Swift HTTP API Proposal project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/AsyncStreaming/Reader/AsyncReader+collect.swift b/Sources/AsyncStreaming/Reader/AsyncReader+collect.swift index c194d06..8068091 100644 --- a/Sources/AsyncStreaming/Reader/AsyncReader+collect.swift +++ b/Sources/AsyncStreaming/Reader/AsyncReader+collect.swift @@ -1,12 +1,11 @@ //===----------------------------------------------------------------------===// // -// This source file is part of the Swift HTTP API Proposal open source project +// This source file is part of the Swift HTTP Server open source project // -// Copyright (c) 2025 Apple Inc. and the Swift HTTP API Proposal project authors +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of Swift HTTP API Proposal project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/AsyncStreaming/Reader/AsyncReader+forEach.swift b/Sources/AsyncStreaming/Reader/AsyncReader+forEach.swift index 6908a8e..91b3549 100644 --- a/Sources/AsyncStreaming/Reader/AsyncReader+forEach.swift +++ b/Sources/AsyncStreaming/Reader/AsyncReader+forEach.swift @@ -1,12 +1,11 @@ //===----------------------------------------------------------------------===// // -// This source file is part of the Swift HTTP API Proposal open source project +// This source file is part of the Swift HTTP Server open source project // -// Copyright (c) 2025 Apple Inc. and the Swift HTTP API Proposal project authors +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of Swift HTTP API Proposal project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/AsyncStreaming/Reader/AsyncReader+map.swift b/Sources/AsyncStreaming/Reader/AsyncReader+map.swift index 3d2c7f5..e4f0bfb 100644 --- a/Sources/AsyncStreaming/Reader/AsyncReader+map.swift +++ b/Sources/AsyncStreaming/Reader/AsyncReader+map.swift @@ -1,12 +1,11 @@ //===----------------------------------------------------------------------===// // -// This source file is part of the Swift HTTP API Proposal open source project +// This source file is part of the Swift HTTP Server open source project // -// Copyright (c) 2025 Apple Inc. and the Swift HTTP API Proposal project authors +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of Swift HTTP API Proposal project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/AsyncStreaming/Reader/AsyncReader.swift b/Sources/AsyncStreaming/Reader/AsyncReader.swift index 68a8e77..981d556 100644 --- a/Sources/AsyncStreaming/Reader/AsyncReader.swift +++ b/Sources/AsyncStreaming/Reader/AsyncReader.swift @@ -1,12 +1,11 @@ //===----------------------------------------------------------------------===// // -// This source file is part of the Swift HTTP API Proposal open source project +// This source file is part of the Swift HTTP Server open source project // -// Copyright (c) 2025 Apple Inc. and the Swift HTTP API Proposal project authors +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of Swift HTTP API Proposal project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/AsyncStreaming/Reader/ConcludingAsyncReader+collect.swift b/Sources/AsyncStreaming/Reader/ConcludingAsyncReader+collect.swift index c2b7f9c..5f0881e 100644 --- a/Sources/AsyncStreaming/Reader/ConcludingAsyncReader+collect.swift +++ b/Sources/AsyncStreaming/Reader/ConcludingAsyncReader+collect.swift @@ -1,12 +1,11 @@ //===----------------------------------------------------------------------===// // -// This source file is part of the Swift HTTP API Proposal open source project +// This source file is part of the Swift HTTP Server open source project // -// Copyright (c) 2025 Apple Inc. and the Swift HTTP API Proposal project authors +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of Swift HTTP API Proposal project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/AsyncStreaming/Reader/ConcludingAsyncReader.swift b/Sources/AsyncStreaming/Reader/ConcludingAsyncReader.swift index fdeb697..b9606f0 100644 --- a/Sources/AsyncStreaming/Reader/ConcludingAsyncReader.swift +++ b/Sources/AsyncStreaming/Reader/ConcludingAsyncReader.swift @@ -1,12 +1,11 @@ //===----------------------------------------------------------------------===// // -// This source file is part of the Swift HTTP API Proposal open source project +// This source file is part of the Swift HTTP Server open source project // -// Copyright (c) 2025 Apple Inc. and the Swift HTTP API Proposal project authors +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of Swift HTTP API Proposal project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/AsyncStreaming/Writer/AsyncWriter+AsyncReader.swift b/Sources/AsyncStreaming/Writer/AsyncWriter+AsyncReader.swift index 6f90f9a..d7bed12 100644 --- a/Sources/AsyncStreaming/Writer/AsyncWriter+AsyncReader.swift +++ b/Sources/AsyncStreaming/Writer/AsyncWriter+AsyncReader.swift @@ -1,12 +1,11 @@ //===----------------------------------------------------------------------===// // -// This source file is part of the Swift HTTP API Proposal open source project +// This source file is part of the Swift HTTP Server open source project // -// Copyright (c) 2025 Apple Inc. and the Swift HTTP API Proposal project authors +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of Swift HTTP API Proposal project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/AsyncStreaming/Writer/AsyncWriter.swift b/Sources/AsyncStreaming/Writer/AsyncWriter.swift index 300e76a..e54d20f 100644 --- a/Sources/AsyncStreaming/Writer/AsyncWriter.swift +++ b/Sources/AsyncStreaming/Writer/AsyncWriter.swift @@ -1,12 +1,11 @@ //===----------------------------------------------------------------------===// // -// This source file is part of the Swift HTTP API Proposal open source project +// This source file is part of the Swift HTTP Server open source project // -// Copyright (c) 2025 Apple Inc. and the Swift HTTP API Proposal project authors +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of Swift HTTP API Proposal project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/AsyncStreaming/Writer/ConcludingAsyncWriter.swift b/Sources/AsyncStreaming/Writer/ConcludingAsyncWriter.swift index b3fd5dd..63bb394 100644 --- a/Sources/AsyncStreaming/Writer/ConcludingAsyncWriter.swift +++ b/Sources/AsyncStreaming/Writer/ConcludingAsyncWriter.swift @@ -1,12 +1,11 @@ //===----------------------------------------------------------------------===// // -// This source file is part of the Swift HTTP API Proposal open source project +// This source file is part of the Swift HTTP Server open source project // -// Copyright (c) 2025 Apple Inc. and the Swift HTTP API Proposal project authors +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of Swift HTTP API Proposal project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/AsyncStreaming/Writer/RigidArray+AsyncWriter.swift b/Sources/AsyncStreaming/Writer/RigidArray+AsyncWriter.swift index a566483..f69fc58 100644 --- a/Sources/AsyncStreaming/Writer/RigidArray+AsyncWriter.swift +++ b/Sources/AsyncStreaming/Writer/RigidArray+AsyncWriter.swift @@ -1,12 +1,11 @@ //===----------------------------------------------------------------------===// // -// This source file is part of the Swift HTTP API Proposal open source project +// This source file is part of the Swift HTTP Server open source project // -// Copyright (c) 2025 Apple Inc. and the Swift HTTP API Proposal project authors +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors // Licensed under Apache License v2.0 // // See LICENSE.txt for license information -// See CONTRIBUTORS.txt for the list of Swift HTTP API Proposal project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/HTTPServer/HTTPRequestContext.swift b/Sources/HTTPServer/HTTPRequestContext.swift index 65aa3ee..4905b9d 100644 --- a/Sources/HTTPServer/HTTPRequestContext.swift +++ b/Sources/HTTPServer/HTTPRequestContext.swift @@ -1,3 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift HTTP Server open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + /// A context object that carries additional information about an HTTP request. /// /// `HTTPRequestContext` provides a way to pass metadata through the HTTP request pipeline. diff --git a/Sources/HTTPServer/NIOHTTPServer+ConnectionContext.swift b/Sources/HTTPServer/NIOHTTPServer+ConnectionContext.swift index 79a698e..c5af49c 100644 --- a/Sources/HTTPServer/NIOHTTPServer+ConnectionContext.swift +++ b/Sources/HTTPServer/NIOHTTPServer+ConnectionContext.swift @@ -1,3 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift HTTP Server open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + import NIOCore import NIOSSL public import X509 diff --git a/Sources/HTTPServer/RequestResponseMiddlewareBox.swift b/Sources/HTTPServer/RequestResponseMiddlewareBox.swift index b2a757d..9c25c97 100644 --- a/Sources/HTTPServer/RequestResponseMiddlewareBox.swift +++ b/Sources/HTTPServer/RequestResponseMiddlewareBox.swift @@ -1,3 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift HTTP Server open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + public import HTTPTypes public import AsyncStreaming diff --git a/Sources/Middleware/ChainedMiddleware.swift b/Sources/Middleware/ChainedMiddleware.swift index feaecc1..5bbe228 100644 --- a/Sources/Middleware/ChainedMiddleware.swift +++ b/Sources/Middleware/ChainedMiddleware.swift @@ -1,3 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift HTTP Server open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + /// A middleware implementation that links two middleware chains together. /// /// ``ChainedMiddleware`` is responsible for properly composing two middleware chains diff --git a/Sources/Middleware/Middleware.swift b/Sources/Middleware/Middleware.swift index ba97ef3..c5bfb32 100644 --- a/Sources/Middleware/Middleware.swift +++ b/Sources/Middleware/Middleware.swift @@ -1,3 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift HTTP Server open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + /// A protocol that defines middleware components for processing inputs and passing them to the next stage. /// /// The `Middleware` protocol provides a way to intercept inputs of type `Input`, diff --git a/Sources/Middleware/MiddlewareBuilder.swift b/Sources/Middleware/MiddlewareBuilder.swift index 3e16713..93f24e4 100644 --- a/Sources/Middleware/MiddlewareBuilder.swift +++ b/Sources/Middleware/MiddlewareBuilder.swift @@ -1,3 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift HTTP Server open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + /// A result builder that enables a declarative syntax for constructing middleware chains. /// /// ``MiddlewareChainBuilder`` leverages Swift's result builder feature to allow developers diff --git a/Sources/Middleware/MiddlewareChain.swift b/Sources/Middleware/MiddlewareChain.swift index 9ea9d4c..f108d24 100644 --- a/Sources/Middleware/MiddlewareChain.swift +++ b/Sources/Middleware/MiddlewareChain.swift @@ -1,3 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift HTTP Server open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + /// A concrete implementation of ``Middleware`` that represents a single middleware or a chain of middlewares. /// /// `MiddlewareChain` provides a structured way to compose middleware components, allowing them diff --git a/Tests/HTTPServerTests/HTTPRequestConcludingAsyncReaderTests.swift b/Tests/HTTPServerTests/HTTPRequestConcludingAsyncReaderTests.swift index 9149dbb..8772721 100644 --- a/Tests/HTTPServerTests/HTTPRequestConcludingAsyncReaderTests.swift +++ b/Tests/HTTPServerTests/HTTPRequestConcludingAsyncReaderTests.swift @@ -1,3 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift HTTP Server open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + import AsyncStreaming @testable import HTTPServer import HTTPTypes diff --git a/Tests/HTTPServerTests/HTTPResponseConcludingAsyncWriterTests.swift b/Tests/HTTPServerTests/HTTPResponseConcludingAsyncWriterTests.swift index b7c1295..c43e3db 100644 --- a/Tests/HTTPServerTests/HTTPResponseConcludingAsyncWriterTests.swift +++ b/Tests/HTTPServerTests/HTTPResponseConcludingAsyncWriterTests.swift @@ -1,3 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift HTTP Server open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + @testable import HTTPServer import HTTPTypes import NIOCore diff --git a/Tests/HTTPServerTests/HTTPResponseSenderTests.swift b/Tests/HTTPServerTests/HTTPResponseSenderTests.swift index 311c248..3547631 100644 --- a/Tests/HTTPServerTests/HTTPResponseSenderTests.swift +++ b/Tests/HTTPServerTests/HTTPResponseSenderTests.swift @@ -1,3 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift HTTP Server open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + @testable import HTTPServer import NIOCore import NIOHTTPTypes diff --git a/Tests/HTTPServerTests/HTTPServerTests.swift b/Tests/HTTPServerTests/HTTPServerTests.swift index 17393af..3dcb123 100644 --- a/Tests/HTTPServerTests/HTTPServerTests.swift +++ b/Tests/HTTPServerTests/HTTPServerTests.swift @@ -11,6 +11,19 @@ // //===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift HTTP Server open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + import HTTPServer import HTTPTypes import Logging diff --git a/Tests/HTTPServerTests/NIOHTTPServerTests.swift b/Tests/HTTPServerTests/NIOHTTPServerTests.swift index f036997..8a08ae7 100644 --- a/Tests/HTTPServerTests/NIOHTTPServerTests.swift +++ b/Tests/HTTPServerTests/NIOHTTPServerTests.swift @@ -11,6 +11,19 @@ // //===----------------------------------------------------------------------===// +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift HTTP Server open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + import HTTPTypes import Logging import NIOCore diff --git a/Tests/HTTPServerTests/Utilities/TestError.swift b/Tests/HTTPServerTests/Utilities/TestError.swift index b88e361..a8d1280 100644 --- a/Tests/HTTPServerTests/Utilities/TestError.swift +++ b/Tests/HTTPServerTests/Utilities/TestError.swift @@ -1,3 +1,16 @@ +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift HTTP Server open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// + // An error type for use in tests enum TestError: Error { case errorWhileReading From d4a344c869d067f3a454b748d5e3f8118d380cfa Mon Sep 17 00:00:00 2001 From: Gus Cairo Date: Wed, 14 Jan 2026 15:33:28 +0000 Subject: [PATCH 3/9] Disable forEach format rule --- Sources/AsyncStreaming/Writer/AsyncWriter+AsyncReader.swift | 1 + .../HTTPServerTests/HTTPRequestConcludingAsyncReaderTests.swift | 1 + 2 files changed, 2 insertions(+) diff --git a/Sources/AsyncStreaming/Writer/AsyncWriter+AsyncReader.swift b/Sources/AsyncStreaming/Writer/AsyncWriter+AsyncReader.swift index d7bed12..84869ff 100644 --- a/Sources/AsyncStreaming/Writer/AsyncWriter+AsyncReader.swift +++ b/Sources/AsyncStreaming/Writer/AsyncWriter+AsyncReader.swift @@ -44,6 +44,7 @@ extension AsyncWriter where Self: ~Copyable, Self: ~Escapable { public mutating func write( _ reader: consuming some (AsyncReader & ~Copyable & ~Escapable) ) async throws(EitherError>) where WriteElement: Copyable { + // swift-format-ignore: ReplaceForEachWithForLoop try await reader.forEach { (span) throws(EitherError) -> Void in try await self.write(span) } diff --git a/Tests/HTTPServerTests/HTTPRequestConcludingAsyncReaderTests.swift b/Tests/HTTPServerTests/HTTPRequestConcludingAsyncReaderTests.swift index 8772721..8cf7c4a 100644 --- a/Tests/HTTPServerTests/HTTPRequestConcludingAsyncReaderTests.swift +++ b/Tests/HTTPServerTests/HTTPRequestConcludingAsyncReaderTests.swift @@ -119,6 +119,7 @@ struct HTTPRequestConcludingAsyncReaderTests { let (_, finalElement) = try await requestReader.consumeAndConclude { bodyReader in // Read all body chunks var chunksProcessed = 0 + // swift-format-ignore: ReplaceForEachWithForLoop try await bodyReader.forEach { element in var buffer = ByteBuffer() buffer.writeBytes(element.bytes) From c83f09a06d4d451fcd2a07971c3c43e700d55d14 Mon Sep 17 00:00:00 2001 From: Gus Cairo Date: Fri, 16 Jan 2026 11:11:30 +0000 Subject: [PATCH 4/9] Formatting --- Package.swift | 9 ++--- .../Internal/InlineArray+convenience.swift | 4 +-- .../Reader/Array+AsyncReader.swift | 2 +- .../Reader/AsyncReader+map.swift | 6 ++-- .../AsyncStreaming/Reader/AsyncReader.swift | 2 +- .../Writer/AsyncWriter+AsyncReader.swift | 3 +- .../AsyncStreaming/Writer/AsyncWriter.swift | 4 ++- Sources/Example/Example.swift | 16 +++++---- .../Middlewares/RouteHandlerMiddleware.swift | 4 +-- .../Middlewares/TimeoutMiddleware.swift | 9 +++-- .../Middlewares/TracingMiddleware.swift | 2 +- .../HTTPRequestConcludingAsyncReader.swift | 3 +- .../HTTPResponseConcludingAsyncWriter.swift | 33 +++++++++---------- Sources/HTTPServer/HTTPResponseSender.swift | 6 ++-- Sources/HTTPServer/HTTPServer.swift | 16 +++++---- .../HTTPServerClosureRequestHandler.swift | 28 ++++++++-------- .../HTTPServer/HTTPServerRequestHandler.swift | 12 ++++--- Sources/HTTPServer/NIOHTTPServer.swift | 12 ++++--- .../NIOHTTPServerConfiguration.swift | 8 +++-- .../RequestResponseMiddlewareBox.swift | 19 ++++++----- Sources/Middleware/MiddlewareChain.swift | 9 ++--- ...TTPRequestConcludingAsyncReaderTests.swift | 10 ++++-- ...TPResponseConcludingAsyncWriterTests.swift | 5 +-- .../HTTPResponseSenderTests.swift | 5 +-- .../HTTPServerTests/NIOHTTPServerTests.swift | 6 +++- 25 files changed, 134 insertions(+), 99 deletions(-) diff --git a/Package.swift b/Package.swift index 06a2998..52fe1fc 100644 --- a/Package.swift +++ b/Package.swift @@ -11,7 +11,7 @@ let extraSettings: [SwiftSetting] = [ .enableUpcomingFeature("InferIsolatedConformances"), .enableUpcomingFeature("ExistentialAny"), .enableUpcomingFeature("MemberImportVisibility"), - .enableUpcomingFeature("InternalImportsByDefault") + .enableUpcomingFeature("InternalImportsByDefault"), ] let package = Package( @@ -19,7 +19,8 @@ let package = Package( products: [ .library( name: "HTTPServer", - targets: ["HTTPServer"]) + targets: ["HTTPServer"] + ) ], dependencies: [ .package( @@ -65,7 +66,7 @@ let package = Package( .product(name: "Logging", package: "swift-log"), .product(name: "NIOHTTPTypesHTTP1", package: "swift-nio-extras"), .product(name: "NIOHTTPTypesHTTP2", package: "swift-nio-extras"), - .product(name: "NIOCertificateReloading", package: "swift-nio-extras") + .product(name: "NIOCertificateReloading", package: "swift-nio-extras"), ], swiftSettings: extraSettings ), @@ -88,7 +89,7 @@ let package = Package( name: "HTTPServerTests", dependencies: [ .product(name: "Logging", package: "swift-log"), - "HTTPServer", + .target(name: "HTTPServer"), ] ), ] diff --git a/Sources/AsyncStreaming/Internal/InlineArray+convenience.swift b/Sources/AsyncStreaming/Internal/InlineArray+convenience.swift index 62a9b83..bbc0767 100644 --- a/Sources/AsyncStreaming/Internal/InlineArray+convenience.swift +++ b/Sources/AsyncStreaming/Internal/InlineArray+convenience.swift @@ -14,10 +14,10 @@ @available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *) extension InlineArray where Element: ~Copyable { package static func one(value: consuming Element) -> InlineArray<1, Element> { - return InlineArray<1, Element>(first: value) { _ in fatalError() } + InlineArray<1, Element>(first: value) { _ in fatalError() } } package static func zero(of elementType: Element.Type = Element.self) -> InlineArray<0, Element> { - return InlineArray<0, Element> { _ in } + InlineArray<0, Element> { _ in } } } diff --git a/Sources/AsyncStreaming/Reader/Array+AsyncReader.swift b/Sources/AsyncStreaming/Reader/Array+AsyncReader.swift index 259b0c6..3ce48bf 100644 --- a/Sources/AsyncStreaming/Reader/Array+AsyncReader.swift +++ b/Sources/AsyncStreaming/Reader/Array+AsyncReader.swift @@ -31,7 +31,7 @@ extension Array { /// } /// ``` public func asyncReader() -> some AsyncReader & SendableMetatype { - return ArrayAsyncReader(array: self) + ArrayAsyncReader(array: self) } } diff --git a/Sources/AsyncStreaming/Reader/AsyncReader+map.swift b/Sources/AsyncStreaming/Reader/AsyncReader+map.swift index e4f0bfb..58dd50d 100644 --- a/Sources/AsyncStreaming/Reader/AsyncReader+map.swift +++ b/Sources/AsyncStreaming/Reader/AsyncReader+map.swift @@ -44,7 +44,7 @@ extension AsyncReader where Self: ~Copyable, Self: ~Escapable { public consuming func map( _ transformation: @escaping (borrowing ReadElement) async -> MappedElement ) -> some (AsyncReader & ~Copyable & ~Escapable) { - return AsyncMapReader(base: self, transformation: transformation) + AsyncMapReader(base: self, transformation: transformation) } } @@ -54,7 +54,9 @@ extension AsyncReader where Self: ~Copyable, Self: ~Escapable { /// to each element read from the base reader. The transformation is applied lazily /// as elements are read, maintaining the streaming nature of the operation. @available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *) -struct AsyncMapReader: AsyncReader, ~Copyable, ~Escapable { +struct AsyncMapReader: AsyncReader, ~Copyable, + ~Escapable +{ typealias ReadElement = MappedElement typealias ReadFailure = Base.ReadFailure diff --git a/Sources/AsyncStreaming/Reader/AsyncReader.swift b/Sources/AsyncStreaming/Reader/AsyncReader.swift index 981d556..b3b2a36 100644 --- a/Sources/AsyncStreaming/Reader/AsyncReader.swift +++ b/Sources/AsyncStreaming/Reader/AsyncReader.swift @@ -101,7 +101,7 @@ extension AsyncReader where Self: ~Copyable, Self: ~Escapable { ) async throws(Failure) -> Return where Self.ReadFailure == Never { do { return try await self.read(maximumCount: maximumCount) { (span) throws(Failure) -> Return in - return try await body(span) + try await body(span) } } catch { switch error { diff --git a/Sources/AsyncStreaming/Writer/AsyncWriter+AsyncReader.swift b/Sources/AsyncStreaming/Writer/AsyncWriter+AsyncReader.swift index 84869ff..df4c5a0 100644 --- a/Sources/AsyncStreaming/Writer/AsyncWriter+AsyncReader.swift +++ b/Sources/AsyncStreaming/Writer/AsyncWriter+AsyncReader.swift @@ -43,7 +43,8 @@ extension AsyncWriter where Self: ~Copyable, Self: ~Escapable { @_lifetime(self: copy self) public mutating func write( _ reader: consuming some (AsyncReader & ~Copyable & ~Escapable) - ) async throws(EitherError>) where WriteElement: Copyable { + ) async throws(EitherError>) + where WriteElement: Copyable { // swift-format-ignore: ReplaceForEachWithForLoop try await reader.forEach { (span) throws(EitherError) -> Void in try await self.write(span) diff --git a/Sources/AsyncStreaming/Writer/AsyncWriter.swift b/Sources/AsyncStreaming/Writer/AsyncWriter.swift index e54d20f..9b7d5c3 100644 --- a/Sources/AsyncStreaming/Writer/AsyncWriter.swift +++ b/Sources/AsyncStreaming/Writer/AsyncWriter.swift @@ -132,7 +132,9 @@ extension AsyncWriter where Self: ~Copyable, Self: ~Escapable { } @_lifetime(self: copy self) - public mutating func write(_ span: Span) async throws(EitherError) + public mutating func write( + _ span: Span + ) async throws(EitherError) where WriteElement: Copyable { var index = span.indices.startIndex while index < span.indices.endIndex { diff --git a/Sources/Example/Example.swift b/Sources/Example/Example.swift index 0e87f9c..f79cde3 100644 --- a/Sources/Example/Example.swift +++ b/Sources/Example/Example.swift @@ -11,6 +11,7 @@ // //===----------------------------------------------------------------------===// +internal import AsyncStreaming import Crypto import Foundation import HTTPServer @@ -19,7 +20,6 @@ import Instrumentation import Logging import Middleware import X509 -internal import AsyncStreaming @main @available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *) @@ -86,12 +86,14 @@ extension NIOHTTPServer { let chain = middlewareBuilder() try await self.serve { request, requestContext, reader, responseSender in - try await chain.intercept(input: RequestResponseMiddlewareBox( - request: request, - requestContext: requestContext, - requestReader: reader, - responseSender: responseSender - )) { _ in } + try await chain.intercept( + input: RequestResponseMiddlewareBox( + request: request, + requestContext: requestContext, + requestReader: reader, + responseSender: responseSender + ) + ) { _ in } } } } diff --git a/Sources/Example/Middlewares/RouteHandlerMiddleware.swift b/Sources/Example/Middlewares/RouteHandlerMiddleware.swift index bf649c6..7c55f65 100644 --- a/Sources/Example/Middlewares/RouteHandlerMiddleware.swift +++ b/Sources/Example/Middlewares/RouteHandlerMiddleware.swift @@ -11,10 +11,10 @@ // //===----------------------------------------------------------------------===// -public import HTTPTypes public import AsyncStreaming -public import Middleware public import HTTPServer +public import HTTPTypes +public import Middleware @available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *) public struct RouteHandlerMiddleware< diff --git a/Sources/Example/Middlewares/TimeoutMiddleware.swift b/Sources/Example/Middlewares/TimeoutMiddleware.swift index de42c6e..a4721b4 100644 --- a/Sources/Example/Middlewares/TimeoutMiddleware.swift +++ b/Sources/Example/Middlewares/TimeoutMiddleware.swift @@ -45,9 +45,12 @@ extension TaskGroup { // This is actually safe. The body closure is async it will hop onto the // right executor automatically. let box = SendableBox(closure: escapingClosure) - self.addTask(name: nil, operation: { - await box.closure() - }) + self.addTask( + name: nil, + operation: { + await box.closure() + } + ) } } } diff --git a/Sources/Example/Middlewares/TracingMiddleware.swift b/Sources/Example/Middlewares/TracingMiddleware.swift index e2eedd2..950689b 100644 --- a/Sources/Example/Middlewares/TracingMiddleware.swift +++ b/Sources/Example/Middlewares/TracingMiddleware.swift @@ -18,7 +18,7 @@ import Tracing @available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *) struct TracingMiddleware: Middleware { typealias NextInput = Input - + func intercept( input: consuming Input, next: (consuming NextInput) async throws -> Void diff --git a/Sources/HTTPServer/HTTPRequestConcludingAsyncReader.swift b/Sources/HTTPServer/HTTPRequestConcludingAsyncReader.swift index 5de42e6..5404589 100644 --- a/Sources/HTTPServer/HTTPRequestConcludingAsyncReader.swift +++ b/Sources/HTTPServer/HTTPRequestConcludingAsyncReader.swift @@ -11,8 +11,8 @@ // //===----------------------------------------------------------------------===// -public import HTTPTypes public import AsyncStreaming +public import HTTPTypes import NIOCore import NIOHTTPTypes import Synchronization @@ -174,7 +174,6 @@ extension HTTPRequestConcludingAsyncReader: Sendable {} @available(*, unavailable) extension HTTPRequestConcludingAsyncReader.RequestBodyAsyncReader: Sendable {} - extension Optional { mutating func sendingTake() -> sending Self { let result = consume self diff --git a/Sources/HTTPServer/HTTPResponseConcludingAsyncWriter.swift b/Sources/HTTPServer/HTTPResponseConcludingAsyncWriter.swift index 073626b..bdc42ef 100644 --- a/Sources/HTTPServer/HTTPResponseConcludingAsyncWriter.swift +++ b/Sources/HTTPServer/HTTPResponseConcludingAsyncWriter.swift @@ -11,9 +11,9 @@ // //===----------------------------------------------------------------------===// -public import HTTPTypes public import AsyncStreaming import BasicContainers +public import HTTPTypes import NIOCore import NIOHTTPTypes import Synchronization @@ -74,10 +74,10 @@ public struct HTTPResponseConcludingAsyncWriter: ConcludingAsyncWriter, ~Copyabl byteBuffer.writeInteger(buffer[index]) } -// buffer.span.withUnsafeBufferPointer { buffer in -// <#code#> -// } -// var byteBuffer = ByteBuffer() + // buffer.span.withUnsafeBufferPointer { buffer in + // <#code#> + // } + // var byteBuffer = ByteBuffer() do { try await self.writer.write(.body(byteBuffer)) @@ -87,18 +87,17 @@ public struct HTTPResponseConcludingAsyncWriter: ConcludingAsyncWriter, ~Copyabl return result - -// let pointer = buffer.withUnsafeMutableBufferPointer { $0 } -// var span = OutputSpan( -// buffer: pointer, -// initializedCount: 0 -// ) -// do { -// let bodyResult = try await body(&span) -// -// } catch { -// throw .second(error) -// } + // let pointer = buffer.withUnsafeMutableBufferPointer { $0 } + // var span = OutputSpan( + // buffer: pointer, + // initializedCount: 0 + // ) + // do { + // let bodyResult = try await body(&span) + // + // } catch { + // throw .second(error) + // } } } diff --git a/Sources/HTTPServer/HTTPResponseSender.swift b/Sources/HTTPServer/HTTPResponseSender.swift index 2ada0e6..42fca9b 100644 --- a/Sources/HTTPServer/HTTPResponseSender.swift +++ b/Sources/HTTPServer/HTTPResponseSender.swift @@ -11,8 +11,8 @@ // //===----------------------------------------------------------------------===// -public import HTTPTypes public import AsyncStreaming +public import HTTPTypes /// This type ensures that a single non-informational (1xx) `HTTPResponse` is sent back to the client when handling a request. /// @@ -35,7 +35,7 @@ public struct HTTPResponseSender - ) async throws -> Void + handler: + nonisolated(nonsending) @Sendable @escaping ( + HTTPRequest, + HTTPRequestContext, + consuming sending ConcludingRequestReader, + consuming sending HTTPResponseSender + ) async throws -> Void ) { self._handler = handler } @@ -114,12 +115,13 @@ extension HTTPServer { /// } /// ``` public func serve( - handler: nonisolated(nonsending) @Sendable @escaping ( - _ request: HTTPRequest, - _ requestContext: HTTPRequestContext, - _ requestBodyAndTrailers: consuming sending RequestReader, - _ responseSender: consuming sending HTTPResponseSender - ) async throws -> Void + handler: + nonisolated(nonsending) @Sendable @escaping ( + _ request: HTTPRequest, + _ requestContext: HTTPRequestContext, + _ requestBodyAndTrailers: consuming sending RequestReader, + _ responseSender: consuming sending HTTPResponseSender + ) async throws -> Void ) async throws { try await self.serve(handler: HTTPServerClosureRequestHandler(handler: handler)) } diff --git a/Sources/HTTPServer/HTTPServerRequestHandler.swift b/Sources/HTTPServer/HTTPServerRequestHandler.swift index 1ba9896..fc3e8f1 100644 --- a/Sources/HTTPServer/HTTPServerRequestHandler.swift +++ b/Sources/HTTPServer/HTTPServerRequestHandler.swift @@ -11,8 +11,8 @@ // //===----------------------------------------------------------------------===// -public import HTTPTypes public import AsyncStreaming +public import HTTPTypes /// A protocol that defines the contract for handling HTTP server requests. /// @@ -76,15 +76,17 @@ public protocol HTTPServerRequestHandler: Sendabl /// must be an optional `HTTPFields`, and ``ConcludingAsyncReader/Underlying`` must use `Span` as its /// `ReadElement`. associatedtype RequestReader: ConcludingAsyncReader & ~Copyable & SendableMetatype - where RequestReader.Underlying.ReadElement == UInt8, - RequestReader.FinalElement == HTTPFields? + where + RequestReader.Underlying.ReadElement == UInt8, + RequestReader.FinalElement == HTTPFields? /// The ``ConcludingAsyncWriter`` to use when writing responses. ``ConcludingAsyncWriter/FinalElement`` /// must be an optional `HTTPFields`, and ``ConcludingAsyncWriter/Underlying`` must use `Span` as its /// `WriteElement`. associatedtype ResponseWriter: ConcludingAsyncWriter & ~Copyable & SendableMetatype - where ResponseWriter.Underlying.WriteElement == UInt8, - ResponseWriter.FinalElement == HTTPFields? + where + ResponseWriter.Underlying.WriteElement == UInt8, + ResponseWriter.FinalElement == HTTPFields? /// Handles an incoming HTTP request and generates a response. /// diff --git a/Sources/HTTPServer/NIOHTTPServer.swift b/Sources/HTTPServer/NIOHTTPServer.swift index 2f4d33c..1f18ca9 100644 --- a/Sources/HTTPServer/NIOHTTPServer.swift +++ b/Sources/HTTPServer/NIOHTTPServer.swift @@ -364,7 +364,8 @@ public struct NIOHTTPServer: HTTPServer { case .http2((let http2Connection, let http2Multiplexer)): do { let chainFuture = http2Connection.nioSSL_peerValidatedCertificateChain() - try await Self.$connectionContext.withValue(ConnectionContext(chainFuture)) { + try await Self.$connectionContext.withValue(ConnectionContext(chainFuture)) + { for try await http2StreamChannel in http2Multiplexer.inbound { connectionGroup.addTask { try await self.handleRequestChannel( @@ -497,9 +498,12 @@ extension NIOHTTPServer { return .certificateVerified(.init(.init(nioSSLCerts))) case .failed(let error): - self.logger.error("Custom certificate verification failed", metadata: [ - "failure-reason": .string(error.reason) - ]) + self.logger.error( + "Custom certificate verification failed", + metadata: [ + "failure-reason": .string(error.reason) + ] + ) return .failed } } diff --git a/Sources/HTTPServer/NIOHTTPServerConfiguration.swift b/Sources/HTTPServer/NIOHTTPServerConfiguration.swift index c41b109..7e05000 100644 --- a/Sources/HTTPServer/NIOHTTPServerConfiguration.swift +++ b/Sources/HTTPServer/NIOHTTPServerConfiguration.swift @@ -66,13 +66,17 @@ public struct NIOHTTPServerConfiguration: Sendable { privateKey: Certificate.PrivateKey, trustRoots: [Certificate]?, certificateVerification: CertificateVerificationMode = .noHostnameVerification, - customCertificateVerificationCallback: (@Sendable ([X509.Certificate]) async throws -> CertificateVerificationResult)? = nil + customCertificateVerificationCallback: ( + @Sendable ([X509.Certificate]) async throws -> CertificateVerificationResult + )? = nil ) case reloadingMTLS( certificateReloader: any CertificateReloader, trustRoots: [Certificate]?, certificateVerification: CertificateVerificationMode = .noHostnameVerification, - customCertificateVerificationCallback: (@Sendable ([X509.Certificate]) async throws -> CertificateVerificationResult)? = nil + customCertificateVerificationCallback: ( + @Sendable ([X509.Certificate]) async throws -> CertificateVerificationResult + )? = nil ) } diff --git a/Sources/HTTPServer/RequestResponseMiddlewareBox.swift b/Sources/HTTPServer/RequestResponseMiddlewareBox.swift index 9c25c97..c87b437 100644 --- a/Sources/HTTPServer/RequestResponseMiddlewareBox.swift +++ b/Sources/HTTPServer/RequestResponseMiddlewareBox.swift @@ -11,8 +11,8 @@ // //===----------------------------------------------------------------------===// -public import HTTPTypes public import AsyncStreaming +public import HTTPTypes /// This type holds the values passed to the ``HTTPServerRequestHandler`` when handling a request. /// It is necessary to box them together so that they can be used with `Middlewares`, as this will be the `Middleware.Input`. @@ -25,7 +25,7 @@ public struct RequestResponseMiddlewareBox< private let requestContext: HTTPRequestContext private let requestReader: RequestReader private let responseSender: HTTPResponseSender - + /// Create a new ``RequestResponseMiddlewareBox``. /// - Parameters: /// - request: The `HTTPRequest`. @@ -42,17 +42,18 @@ public struct RequestResponseMiddlewareBox< self.requestReader = requestReader self.responseSender = responseSender } - + /// Provides a closure exposing the request, request reader and response sender contained in this box. /// - Parameter handler: The handler for this box's contents. /// - Returns: The value returned from `handler`. public consuming func withContents( - _ handler: nonisolated(nonsending) ( - HTTPRequest, - HTTPRequestContext, - consuming RequestReader, - consuming HTTPResponseSender - ) async throws -> T + _ handler: + nonisolated(nonsending) ( + HTTPRequest, + HTTPRequestContext, + consuming RequestReader, + consuming HTTPResponseSender + ) async throws -> T ) async throws -> T { try await handler( self.request, diff --git a/Sources/Middleware/MiddlewareChain.swift b/Sources/Middleware/MiddlewareChain.swift index f108d24..ba8a3a3 100644 --- a/Sources/Middleware/MiddlewareChain.swift +++ b/Sources/Middleware/MiddlewareChain.swift @@ -43,10 +43,11 @@ public struct MiddlewareChain: Middlewar /// /// - Parameter middlewareFunc: A closure that implements the middleware's behavior. init( - middlewareFunc: nonisolated(nonsending) @Sendable @escaping ( - consuming Input, - (consuming NextInput) async throws -> Void - ) async throws -> Void + middlewareFunc: + nonisolated(nonsending) @Sendable @escaping ( + consuming Input, + (consuming NextInput) async throws -> Void + ) async throws -> Void ) { self.middlewareFunc = middlewareFunc } diff --git a/Tests/HTTPServerTests/HTTPRequestConcludingAsyncReaderTests.swift b/Tests/HTTPServerTests/HTTPRequestConcludingAsyncReaderTests.swift index 8cf7c4a..7dfa4c5 100644 --- a/Tests/HTTPServerTests/HTTPRequestConcludingAsyncReaderTests.swift +++ b/Tests/HTTPServerTests/HTTPRequestConcludingAsyncReaderTests.swift @@ -12,7 +12,6 @@ //===----------------------------------------------------------------------===// import AsyncStreaming -@testable import HTTPServer import HTTPTypes import NIOCore import NIOHTTP1 @@ -20,6 +19,8 @@ import NIOHTTPTypes import NIOPosix import Testing +@testable import HTTPServer + @Suite struct HTTPRequestConcludingAsyncReaderTests { @Test("Head request not allowed") @@ -50,7 +51,7 @@ struct HTTPRequestConcludingAsyncReaderTests { arguments: [ByteBuffer(repeating: 1, count: 100), ByteBuffer()], [ HTTPFields([.init(name: .cookie, value: "test_cookie")]), - HTTPFields([.init(name: .cookie, value: "first_cookie"), .init(name: .cookie, value: "second_cookie")]) + HTTPFields([.init(name: .cookie, value: "first_cookie"), .init(name: .cookie, value: "second_cookie")]), ] ) @available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *) @@ -177,7 +178,10 @@ struct HTTPRequestConcludingAsyncReaderTests { source.yield(.body(.init(repeating: 5, count: 10))) source.finish() - let requestReader = HTTPRequestConcludingAsyncReader(iterator: stream.makeAsyncIterator(), readerState: .init()) + let requestReader = HTTPRequestConcludingAsyncReader( + iterator: stream.makeAsyncIterator(), + readerState: .init() + ) _ = try await requestReader.consumeAndConclude { requestBodyReader in var requestBodyReader = requestBodyReader diff --git a/Tests/HTTPServerTests/HTTPResponseConcludingAsyncWriterTests.swift b/Tests/HTTPServerTests/HTTPResponseConcludingAsyncWriterTests.swift index c43e3db..94f19b6 100644 --- a/Tests/HTTPServerTests/HTTPResponseConcludingAsyncWriterTests.swift +++ b/Tests/HTTPServerTests/HTTPResponseConcludingAsyncWriterTests.swift @@ -11,12 +11,13 @@ // //===----------------------------------------------------------------------===// -@testable import HTTPServer import HTTPTypes import NIOCore import NIOHTTPTypes import Testing +@testable import HTTPServer + @Suite struct HTTPResponseConcludingAsyncWriterTests { let bodySampleOne: UInt8 = 1 @@ -128,7 +129,7 @@ struct HTTPResponseConcludingAsyncWriterTests { let responseWriter = HTTPResponseConcludingAsyncWriter(writer: writer, writerState: .init()) try await responseWriter.produceAndConclude { bodyWriter in - return self.trailerSampleTwo + self.trailerSampleTwo } var responseIterator = sink.makeAsyncIterator() diff --git a/Tests/HTTPServerTests/HTTPResponseSenderTests.swift b/Tests/HTTPServerTests/HTTPResponseSenderTests.swift index 3547631..cc7bdc0 100644 --- a/Tests/HTTPServerTests/HTTPResponseSenderTests.swift +++ b/Tests/HTTPServerTests/HTTPResponseSenderTests.swift @@ -11,12 +11,13 @@ // //===----------------------------------------------------------------------===// -@testable import HTTPServer +import HTTPTypes import NIOCore import NIOHTTPTypes -import HTTPTypes import Testing +@testable import HTTPServer + @Suite struct HTTPResponseSenderTests { @Test("Informational header without informational status code") diff --git a/Tests/HTTPServerTests/NIOHTTPServerTests.swift b/Tests/HTTPServerTests/NIOHTTPServerTests.swift index 8a08ae7..53f46ff 100644 --- a/Tests/HTTPServerTests/NIOHTTPServerTests.swift +++ b/Tests/HTTPServerTests/NIOHTTPServerTests.swift @@ -145,7 +145,11 @@ struct NIOHTTPServerTests { } @available(macOS 26.0, iOS 26.0, watchOS 26.0, tvOS 26.0, visionOS 26.0, *) - @Test("mTLS request-response with custom verification callback returning peer certificates", .serialized, arguments: ["http/1.1", "h2"]) + @Test( + "mTLS request-response with custom verification callback returning peer certificates", + .serialized, + arguments: ["http/1.1", "h2"] + ) func testMTLS(applicationProtocol: String) async throws { let serverChain = try TestCA.makeSelfSignedChain() let clientChain = try TestCA.makeSelfSignedChain() From 73b4894557fca98f0440f132df2aec23d01e7034 Mon Sep 17 00:00:00 2001 From: Gus Cairo Date: Mon, 19 Jan 2026 10:55:53 +0000 Subject: [PATCH 5/9] Rename package to fix build issue on Linux --- Package.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Package.swift b/Package.swift index 52fe1fc..03182ca 100644 --- a/Package.swift +++ b/Package.swift @@ -15,7 +15,7 @@ let extraSettings: [SwiftSetting] = [ ] let package = Package( - name: "HTTPServer", + name: "swift-http-server", products: [ .library( name: "HTTPServer", @@ -89,7 +89,7 @@ let package = Package( name: "HTTPServerTests", dependencies: [ .product(name: "Logging", package: "swift-log"), - .target(name: "HTTPServer"), + "HTTPServer", ] ), ] From 191fdb4e63fb49877d639476f08b3fac2d44f495 Mon Sep 17 00:00:00 2001 From: Gus Cairo Date: Mon, 19 Jan 2026 10:59:35 +0000 Subject: [PATCH 6/9] Fix license headers --- Sources/AsyncStreaming/EitherError.swift | 1 + .../Internal/InlineArray+convenience.swift | 1 + .../Internal/Optional+SendingTake.swift | 1 + .../AsyncStreaming/Reader/Array+AsyncReader.swift | 1 + .../Reader/AsyncReader+collect.swift | 1 + .../Reader/AsyncReader+forEach.swift | 1 + .../AsyncStreaming/Reader/AsyncReader+map.swift | 1 + Sources/AsyncStreaming/Reader/AsyncReader.swift | 1 + .../Reader/ConcludingAsyncReader+collect.swift | 1 + .../Reader/ConcludingAsyncReader.swift | 1 + .../Writer/AsyncWriter+AsyncReader.swift | 1 + Sources/AsyncStreaming/Writer/AsyncWriter.swift | 1 + .../Writer/ConcludingAsyncWriter.swift | 1 + .../Writer/RigidArray+AsyncWriter.swift | 1 + Sources/Example/Example.swift | 1 + Sources/Example/LogTracer.swift | 1 + .../Middlewares/HTTPRequestLoggingMiddleware.swift | 1 + .../Middlewares/RouteHandlerMiddleware.swift | 1 + .../Example/Middlewares/TimeoutMiddleware.swift | 1 + .../Example/Middlewares/TracingMiddleware.swift | 1 + .../HTTPRequestConcludingAsyncReader.swift | 1 + Sources/HTTPServer/HTTPRequestContext.swift | 1 + .../HTTPResponseConcludingAsyncWriter.swift | 1 + Sources/HTTPServer/HTTPResponseSender.swift | 1 + Sources/HTTPServer/HTTPServer.swift | 1 + .../HTTPServerClosureRequestHandler.swift | 1 + Sources/HTTPServer/HTTPServerRequestHandler.swift | 1 + .../NIOHTTPServer+ConnectionContext.swift | 1 + .../NIOHTTPServer+ListeningAddress.swift | 1 + Sources/HTTPServer/NIOHTTPServer.swift | 1 + .../HTTPServer/NIOHTTPServerConfiguration.swift | 1 + Sources/HTTPServer/NIOSSL+X509.swift | 1 + .../HTTPServer/RequestResponseMiddlewareBox.swift | 1 + Sources/HTTPServer/SocketAddress.swift | 1 + Sources/Middleware/ChainedMiddleware.swift | 1 + Sources/Middleware/Middleware.swift | 1 + Sources/Middleware/MiddlewareBuilder.swift | 1 + Sources/Middleware/MiddlewareChain.swift | 1 + .../HTTPRequestConcludingAsyncReaderTests.swift | 1 + .../HTTPResponseConcludingAsyncWriterTests.swift | 1 + .../HTTPServerTests/HTTPResponseSenderTests.swift | 1 + Tests/HTTPServerTests/HTTPServerTests.swift | 14 +------------- Tests/HTTPServerTests/NIOHTTPServerTests.swift | 14 +------------- Tests/HTTPServerTests/Utilities/Certificates.swift | 1 + Tests/HTTPServerTests/Utilities/Client.swift | 1 + Tests/HTTPServerTests/Utilities/TestError.swift | 1 + 46 files changed, 46 insertions(+), 26 deletions(-) diff --git a/Sources/AsyncStreaming/EitherError.swift b/Sources/AsyncStreaming/EitherError.swift index 593e17f..d01a0a9 100644 --- a/Sources/AsyncStreaming/EitherError.swift +++ b/Sources/AsyncStreaming/EitherError.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/AsyncStreaming/Internal/InlineArray+convenience.swift b/Sources/AsyncStreaming/Internal/InlineArray+convenience.swift index bbc0767..59a6c2f 100644 --- a/Sources/AsyncStreaming/Internal/InlineArray+convenience.swift +++ b/Sources/AsyncStreaming/Internal/InlineArray+convenience.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/AsyncStreaming/Internal/Optional+SendingTake.swift b/Sources/AsyncStreaming/Internal/Optional+SendingTake.swift index 570a846..2702130 100644 --- a/Sources/AsyncStreaming/Internal/Optional+SendingTake.swift +++ b/Sources/AsyncStreaming/Internal/Optional+SendingTake.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/AsyncStreaming/Reader/Array+AsyncReader.swift b/Sources/AsyncStreaming/Reader/Array+AsyncReader.swift index 3ce48bf..f09e0f3 100644 --- a/Sources/AsyncStreaming/Reader/Array+AsyncReader.swift +++ b/Sources/AsyncStreaming/Reader/Array+AsyncReader.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/AsyncStreaming/Reader/AsyncReader+collect.swift b/Sources/AsyncStreaming/Reader/AsyncReader+collect.swift index 8068091..3ceb3c4 100644 --- a/Sources/AsyncStreaming/Reader/AsyncReader+collect.swift +++ b/Sources/AsyncStreaming/Reader/AsyncReader+collect.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/AsyncStreaming/Reader/AsyncReader+forEach.swift b/Sources/AsyncStreaming/Reader/AsyncReader+forEach.swift index 91b3549..75f6b75 100644 --- a/Sources/AsyncStreaming/Reader/AsyncReader+forEach.swift +++ b/Sources/AsyncStreaming/Reader/AsyncReader+forEach.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/AsyncStreaming/Reader/AsyncReader+map.swift b/Sources/AsyncStreaming/Reader/AsyncReader+map.swift index 58dd50d..09f8374 100644 --- a/Sources/AsyncStreaming/Reader/AsyncReader+map.swift +++ b/Sources/AsyncStreaming/Reader/AsyncReader+map.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/AsyncStreaming/Reader/AsyncReader.swift b/Sources/AsyncStreaming/Reader/AsyncReader.swift index b3b2a36..4e3a669 100644 --- a/Sources/AsyncStreaming/Reader/AsyncReader.swift +++ b/Sources/AsyncStreaming/Reader/AsyncReader.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/AsyncStreaming/Reader/ConcludingAsyncReader+collect.swift b/Sources/AsyncStreaming/Reader/ConcludingAsyncReader+collect.swift index 5f0881e..a7ea53a 100644 --- a/Sources/AsyncStreaming/Reader/ConcludingAsyncReader+collect.swift +++ b/Sources/AsyncStreaming/Reader/ConcludingAsyncReader+collect.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/AsyncStreaming/Reader/ConcludingAsyncReader.swift b/Sources/AsyncStreaming/Reader/ConcludingAsyncReader.swift index b9606f0..ecd22a8 100644 --- a/Sources/AsyncStreaming/Reader/ConcludingAsyncReader.swift +++ b/Sources/AsyncStreaming/Reader/ConcludingAsyncReader.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/AsyncStreaming/Writer/AsyncWriter+AsyncReader.swift b/Sources/AsyncStreaming/Writer/AsyncWriter+AsyncReader.swift index df4c5a0..09b5afd 100644 --- a/Sources/AsyncStreaming/Writer/AsyncWriter+AsyncReader.swift +++ b/Sources/AsyncStreaming/Writer/AsyncWriter+AsyncReader.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/AsyncStreaming/Writer/AsyncWriter.swift b/Sources/AsyncStreaming/Writer/AsyncWriter.swift index 9b7d5c3..6daec0b 100644 --- a/Sources/AsyncStreaming/Writer/AsyncWriter.swift +++ b/Sources/AsyncStreaming/Writer/AsyncWriter.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/AsyncStreaming/Writer/ConcludingAsyncWriter.swift b/Sources/AsyncStreaming/Writer/ConcludingAsyncWriter.swift index 63bb394..2daa6c2 100644 --- a/Sources/AsyncStreaming/Writer/ConcludingAsyncWriter.swift +++ b/Sources/AsyncStreaming/Writer/ConcludingAsyncWriter.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/AsyncStreaming/Writer/RigidArray+AsyncWriter.swift b/Sources/AsyncStreaming/Writer/RigidArray+AsyncWriter.swift index f69fc58..c73a743 100644 --- a/Sources/AsyncStreaming/Writer/RigidArray+AsyncWriter.swift +++ b/Sources/AsyncStreaming/Writer/RigidArray+AsyncWriter.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/Example/Example.swift b/Sources/Example/Example.swift index f79cde3..aac137e 100644 --- a/Sources/Example/Example.swift +++ b/Sources/Example/Example.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/Example/LogTracer.swift b/Sources/Example/LogTracer.swift index ae8dce6..5c1bf8d 100644 --- a/Sources/Example/LogTracer.swift +++ b/Sources/Example/LogTracer.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/Example/Middlewares/HTTPRequestLoggingMiddleware.swift b/Sources/Example/Middlewares/HTTPRequestLoggingMiddleware.swift index 6a45f4b..a9936b5 100644 --- a/Sources/Example/Middlewares/HTTPRequestLoggingMiddleware.swift +++ b/Sources/Example/Middlewares/HTTPRequestLoggingMiddleware.swift @@ -8,6 +8,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/Example/Middlewares/RouteHandlerMiddleware.swift b/Sources/Example/Middlewares/RouteHandlerMiddleware.swift index 7c55f65..00093cd 100644 --- a/Sources/Example/Middlewares/RouteHandlerMiddleware.swift +++ b/Sources/Example/Middlewares/RouteHandlerMiddleware.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/Example/Middlewares/TimeoutMiddleware.swift b/Sources/Example/Middlewares/TimeoutMiddleware.swift index a4721b4..77dc314 100644 --- a/Sources/Example/Middlewares/TimeoutMiddleware.swift +++ b/Sources/Example/Middlewares/TimeoutMiddleware.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/Example/Middlewares/TracingMiddleware.swift b/Sources/Example/Middlewares/TracingMiddleware.swift index 950689b..eddc42e 100644 --- a/Sources/Example/Middlewares/TracingMiddleware.swift +++ b/Sources/Example/Middlewares/TracingMiddleware.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/HTTPServer/HTTPRequestConcludingAsyncReader.swift b/Sources/HTTPServer/HTTPRequestConcludingAsyncReader.swift index 5404589..dbb6646 100644 --- a/Sources/HTTPServer/HTTPRequestConcludingAsyncReader.swift +++ b/Sources/HTTPServer/HTTPRequestConcludingAsyncReader.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/HTTPServer/HTTPRequestContext.swift b/Sources/HTTPServer/HTTPRequestContext.swift index 4905b9d..b6e528a 100644 --- a/Sources/HTTPServer/HTTPRequestContext.swift +++ b/Sources/HTTPServer/HTTPRequestContext.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/HTTPServer/HTTPResponseConcludingAsyncWriter.swift b/Sources/HTTPServer/HTTPResponseConcludingAsyncWriter.swift index bdc42ef..38135a6 100644 --- a/Sources/HTTPServer/HTTPResponseConcludingAsyncWriter.swift +++ b/Sources/HTTPServer/HTTPResponseConcludingAsyncWriter.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/HTTPServer/HTTPResponseSender.swift b/Sources/HTTPServer/HTTPResponseSender.swift index 42fca9b..a1dc437 100644 --- a/Sources/HTTPServer/HTTPResponseSender.swift +++ b/Sources/HTTPServer/HTTPResponseSender.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/HTTPServer/HTTPServer.swift b/Sources/HTTPServer/HTTPServer.swift index c4e6ea7..c1ce69f 100644 --- a/Sources/HTTPServer/HTTPServer.swift +++ b/Sources/HTTPServer/HTTPServer.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/HTTPServer/HTTPServerClosureRequestHandler.swift b/Sources/HTTPServer/HTTPServerClosureRequestHandler.swift index 4940f13..2eeedd7 100644 --- a/Sources/HTTPServer/HTTPServerClosureRequestHandler.swift +++ b/Sources/HTTPServer/HTTPServerClosureRequestHandler.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/HTTPServer/HTTPServerRequestHandler.swift b/Sources/HTTPServer/HTTPServerRequestHandler.swift index fc3e8f1..ffc1e41 100644 --- a/Sources/HTTPServer/HTTPServerRequestHandler.swift +++ b/Sources/HTTPServer/HTTPServerRequestHandler.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/HTTPServer/NIOHTTPServer+ConnectionContext.swift b/Sources/HTTPServer/NIOHTTPServer+ConnectionContext.swift index c5af49c..774e276 100644 --- a/Sources/HTTPServer/NIOHTTPServer+ConnectionContext.swift +++ b/Sources/HTTPServer/NIOHTTPServer+ConnectionContext.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/HTTPServer/NIOHTTPServer+ListeningAddress.swift b/Sources/HTTPServer/NIOHTTPServer+ListeningAddress.swift index 2fb2c3b..94af116 100644 --- a/Sources/HTTPServer/NIOHTTPServer+ListeningAddress.swift +++ b/Sources/HTTPServer/NIOHTTPServer+ListeningAddress.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/HTTPServer/NIOHTTPServer.swift b/Sources/HTTPServer/NIOHTTPServer.swift index 1f18ca9..083f0f0 100644 --- a/Sources/HTTPServer/NIOHTTPServer.swift +++ b/Sources/HTTPServer/NIOHTTPServer.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/HTTPServer/NIOHTTPServerConfiguration.swift b/Sources/HTTPServer/NIOHTTPServerConfiguration.swift index 7e05000..c4118eb 100644 --- a/Sources/HTTPServer/NIOHTTPServerConfiguration.swift +++ b/Sources/HTTPServer/NIOHTTPServerConfiguration.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/HTTPServer/NIOSSL+X509.swift b/Sources/HTTPServer/NIOSSL+X509.swift index 863b6db..b2dc416 100644 --- a/Sources/HTTPServer/NIOSSL+X509.swift +++ b/Sources/HTTPServer/NIOSSL+X509.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/HTTPServer/RequestResponseMiddlewareBox.swift b/Sources/HTTPServer/RequestResponseMiddlewareBox.swift index c87b437..e54bc24 100644 --- a/Sources/HTTPServer/RequestResponseMiddlewareBox.swift +++ b/Sources/HTTPServer/RequestResponseMiddlewareBox.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/HTTPServer/SocketAddress.swift b/Sources/HTTPServer/SocketAddress.swift index dffee35..bc14abe 100644 --- a/Sources/HTTPServer/SocketAddress.swift +++ b/Sources/HTTPServer/SocketAddress.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/Middleware/ChainedMiddleware.swift b/Sources/Middleware/ChainedMiddleware.swift index 5bbe228..29e80da 100644 --- a/Sources/Middleware/ChainedMiddleware.swift +++ b/Sources/Middleware/ChainedMiddleware.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/Middleware/Middleware.swift b/Sources/Middleware/Middleware.swift index c5bfb32..c4f10e3 100644 --- a/Sources/Middleware/Middleware.swift +++ b/Sources/Middleware/Middleware.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/Middleware/MiddlewareBuilder.swift b/Sources/Middleware/MiddlewareBuilder.swift index 93f24e4..5433bc2 100644 --- a/Sources/Middleware/MiddlewareBuilder.swift +++ b/Sources/Middleware/MiddlewareBuilder.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Sources/Middleware/MiddlewareChain.swift b/Sources/Middleware/MiddlewareChain.swift index ba8a3a3..90b2176 100644 --- a/Sources/Middleware/MiddlewareChain.swift +++ b/Sources/Middleware/MiddlewareChain.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Tests/HTTPServerTests/HTTPRequestConcludingAsyncReaderTests.swift b/Tests/HTTPServerTests/HTTPRequestConcludingAsyncReaderTests.swift index 7dfa4c5..82baa80 100644 --- a/Tests/HTTPServerTests/HTTPRequestConcludingAsyncReaderTests.swift +++ b/Tests/HTTPServerTests/HTTPRequestConcludingAsyncReaderTests.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Tests/HTTPServerTests/HTTPResponseConcludingAsyncWriterTests.swift b/Tests/HTTPServerTests/HTTPResponseConcludingAsyncWriterTests.swift index 94f19b6..4302368 100644 --- a/Tests/HTTPServerTests/HTTPResponseConcludingAsyncWriterTests.swift +++ b/Tests/HTTPServerTests/HTTPResponseConcludingAsyncWriterTests.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Tests/HTTPServerTests/HTTPResponseSenderTests.swift b/Tests/HTTPServerTests/HTTPResponseSenderTests.swift index cc7bdc0..03a1a13 100644 --- a/Tests/HTTPServerTests/HTTPResponseSenderTests.swift +++ b/Tests/HTTPServerTests/HTTPResponseSenderTests.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Tests/HTTPServerTests/HTTPServerTests.swift b/Tests/HTTPServerTests/HTTPServerTests.swift index 3dcb123..673505f 100644 --- a/Tests/HTTPServerTests/HTTPServerTests.swift +++ b/Tests/HTTPServerTests/HTTPServerTests.swift @@ -6,19 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information -// -// SPDX-License-Identifier: Apache-2.0 -// -//===----------------------------------------------------------------------===// - -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift HTTP Server open source project -// -// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors -// Licensed under Apache License v2.0 -// -// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Tests/HTTPServerTests/NIOHTTPServerTests.swift b/Tests/HTTPServerTests/NIOHTTPServerTests.swift index 53f46ff..e61cca6 100644 --- a/Tests/HTTPServerTests/NIOHTTPServerTests.swift +++ b/Tests/HTTPServerTests/NIOHTTPServerTests.swift @@ -6,19 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information -// -// SPDX-License-Identifier: Apache-2.0 -// -//===----------------------------------------------------------------------===// - -//===----------------------------------------------------------------------===// -// -// This source file is part of the Swift HTTP Server open source project -// -// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors -// Licensed under Apache License v2.0 -// -// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Tests/HTTPServerTests/Utilities/Certificates.swift b/Tests/HTTPServerTests/Utilities/Certificates.swift index e6afb1a..20c80c4 100644 --- a/Tests/HTTPServerTests/Utilities/Certificates.swift +++ b/Tests/HTTPServerTests/Utilities/Certificates.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Tests/HTTPServerTests/Utilities/Client.swift b/Tests/HTTPServerTests/Utilities/Client.swift index 8439831..ba43022 100644 --- a/Tests/HTTPServerTests/Utilities/Client.swift +++ b/Tests/HTTPServerTests/Utilities/Client.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // diff --git a/Tests/HTTPServerTests/Utilities/TestError.swift b/Tests/HTTPServerTests/Utilities/TestError.swift index a8d1280..0874e0e 100644 --- a/Tests/HTTPServerTests/Utilities/TestError.swift +++ b/Tests/HTTPServerTests/Utilities/TestError.swift @@ -6,6 +6,7 @@ // Licensed under Apache License v2.0 // // See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors // // SPDX-License-Identifier: Apache-2.0 // From 5d41abafcce5e6f5cb15261394c4a4028f1b3167 Mon Sep 17 00:00:00 2001 From: Gus Cairo Date: Mon, 19 Jan 2026 11:01:34 +0000 Subject: [PATCH 7/9] Fix license header issue --- .../Example/Middlewares/HTTPRequestLoggingMiddleware.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Sources/Example/Middlewares/HTTPRequestLoggingMiddleware.swift b/Sources/Example/Middlewares/HTTPRequestLoggingMiddleware.swift index a9936b5..60de831 100644 --- a/Sources/Example/Middlewares/HTTPRequestLoggingMiddleware.swift +++ b/Sources/Example/Middlewares/HTTPRequestLoggingMiddleware.swift @@ -1,5 +1,3 @@ -// This is currently commented out because a compiler bug is causing issues. - //===----------------------------------------------------------------------===// // // This source file is part of the Swift HTTP Server open source project @@ -14,6 +12,8 @@ // //===----------------------------------------------------------------------===// +// This is currently commented out because a compiler bug is causing issues. + //import HTTPServer //import HTTPTypes //import Logging From c2b480ab3e6d716dc47ed80704bb4c40343a823f Mon Sep 17 00:00:00 2001 From: Gus Cairo Date: Mon, 19 Jan 2026 11:03:50 +0000 Subject: [PATCH 8/9] Add license header to package manifest --- Package.swift | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/Package.swift b/Package.swift index 03182ca..cf3616f 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,17 @@ -// swift-tools-version: 6.2 +// swift-tools-version:6.2 +//===----------------------------------------------------------------------===// +// +// This source file is part of the Swift HTTP Server open source project +// +// Copyright (c) 2025 Apple Inc. and the Swift HTTP Server project authors +// Licensed under Apache License v2.0 +// +// See LICENSE.txt for license information +// See CONTRIBUTORS.txt for the list of Swift HTTP Server project authors +// +// SPDX-License-Identifier: Apache-2.0 +// +//===----------------------------------------------------------------------===// import PackageDescription From 16fd5cdc93abeee8604ca40f6da2e2b3b1e832ec Mon Sep 17 00:00:00 2001 From: Gus Cairo Date: Mon, 19 Jan 2026 11:14:18 +0000 Subject: [PATCH 9/9] Add .licenseignore --- .licenseignore | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .licenseignore diff --git a/.licenseignore b/.licenseignore new file mode 100644 index 0000000..dac076b --- /dev/null +++ b/.licenseignore @@ -0,0 +1,28 @@ +.gitignore +**/.gitignore +.licenseignore +.gitattributes +.git-blame-ignore-revs +.mailfilter +.mailmap +.spi.yml +.swift-format +.editorconfig +.github/* +*.md +*.txt +*.yml +*.yaml +*.json +Package.swift +**/Package.swift +Package@-*.swift +**/Package@-*.swift +Package.resolved +**/Package.resolved +Makefile +*.modulemap +**/*.modulemap +**/*.docc/* +*.xcprivacy +**/*.xcprivacy