From 5c1a75099c621c0809a01d2065b7c4355b272c8f Mon Sep 17 00:00:00 2001 From: Guoye Zhang Date: Wed, 8 Apr 2026 15:14:12 -0700 Subject: [PATCH 01/10] Support embedded Swift --- Sources/HTTPTypes/HTTPField.swift | 4 ++++ Sources/HTTPTypes/HTTPFieldName.swift | 4 ++++ Sources/HTTPTypes/HTTPFields.swift | 26 +++++++++++++++++++----- Sources/HTTPTypes/HTTPParsedFields.swift | 4 ++++ Sources/HTTPTypes/HTTPRequest+URL.swift | 4 ++++ Sources/HTTPTypes/HTTPRequest.swift | 4 ++++ Sources/HTTPTypes/HTTPResponse.swift | 4 ++++ 7 files changed, 45 insertions(+), 5 deletions(-) diff --git a/Sources/HTTPTypes/HTTPField.swift b/Sources/HTTPTypes/HTTPField.swift index 8645aa9..e7601bc 100644 --- a/Sources/HTTPTypes/HTTPField.swift +++ b/Sources/HTTPTypes/HTTPField.swift @@ -219,6 +219,8 @@ extension HTTPField: CustomStringConvertible { } } +#if !hasFeature(Embedded) + extension HTTPField: CustomPlaygroundDisplayConvertible { public var playgroundDescription: Any { self.description @@ -261,6 +263,8 @@ extension HTTPField: Codable { } } +#endif + extension HTTPField { static func isValidToken(_ token: some StringProtocol) -> Bool { !token.isEmpty diff --git a/Sources/HTTPTypes/HTTPFieldName.swift b/Sources/HTTPTypes/HTTPFieldName.swift index 550505e..d052210 100644 --- a/Sources/HTTPTypes/HTTPFieldName.swift +++ b/Sources/HTTPTypes/HTTPFieldName.swift @@ -111,6 +111,8 @@ extension HTTPField.Name: LosslessStringConvertible { } } +#if !hasFeature(Embedded) + extension HTTPField.Name: CustomPlaygroundDisplayConvertible { public var playgroundDescription: Any { self.description @@ -148,6 +150,8 @@ extension HTTPField.Name: Codable { } } +#endif + extension HTTPField.Name { static var method: Self { .init(rawName: ":method", canonicalName: ":method") } static var scheme: Self { .init(rawName: ":scheme", canonicalName: ":scheme") } diff --git a/Sources/HTTPTypes/HTTPFields.swift b/Sources/HTTPTypes/HTTPFields.swift index af22e9f..97a0b47 100644 --- a/Sources/HTTPTypes/HTTPFields.swift +++ b/Sources/HTTPTypes/HTTPFields.swift @@ -30,9 +30,15 @@ public struct HTTPFields: Sendable, Hashable { required init() { } + #if !hasFeature(Embedded) func withLock(_ body: () throws -> Result) rethrows -> Result { fatalError() } + #else + final func withLock(_ body: () throws -> Result) rethrows -> Result { + try body() + } + #endif var ensureIndex: [String: (first: UInt16, last: UInt16)] { self.withLock { @@ -107,6 +113,7 @@ public struct HTTPFields: Sendable, Hashable { } } + #if !hasFeature(Embedded) @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) private final class _StorageWithMutex: _Storage, @unchecked Sendable { let mutex = Mutex(()) @@ -129,9 +136,12 @@ public struct HTTPFields: Sendable, Hashable { } } #endif + #endif private var _storage = { - #if canImport(Darwin) + #if hasFeature(Embedded) + _Storage() + #elseif canImport(Darwin) if #available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) { _StorageWithMutex() } else { @@ -166,13 +176,14 @@ public struct HTTPFields: Sendable, Hashable { let fields = self.fields(for: name) if fields.first(where: { _ in true }) != nil { let separator = name == .cookie ? "; " : ", " - return fields.lazy.map(\.value).joined(separator: separator) + return fields.lazy.map { $0.value }.joined(separator: separator) } else { return nil } } set { if let newValue { + #if !hasFeature(Embedded) if #available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *), name == .cookie { @@ -182,9 +193,10 @@ public struct HTTPFields: Sendable, Hashable { }, for: name ) - } else { - self.setFields(CollectionOfOne(HTTPField(name: name, value: newValue)), for: name) + return } + #endif + self.setFields(CollectionOfOne(HTTPField(name: name, value: newValue)), for: name) } else { self.setFields(EmptyCollection(), for: name) } @@ -194,7 +206,7 @@ public struct HTTPFields: Sendable, Hashable { /// Access the field values by name as an array of strings. The order of fields is preserved. public subscript(values name: HTTPField.Name) -> [String] { get { - self.fields(for: name).map(\.value) + self.fields(for: name).map { $0.value } } set { self.setFields(newValue.lazy.map { HTTPField(name: name, value: $0) }, for: name) @@ -355,6 +367,8 @@ extension HTTPFields: RangeReplaceableCollection, RandomAccessCollection, Mutabl } } +#if !hasFeature(Embedded) + extension HTTPFields: CustomDebugStringConvertible { public var debugDescription: String { self._storage.fields.description @@ -385,6 +399,8 @@ extension HTTPFields: Codable { } } +#endif + extension Array { // `removalIndices` must be ordered. mutating func remove(at removalIndices: some Sequence) { diff --git a/Sources/HTTPTypes/HTTPParsedFields.swift b/Sources/HTTPTypes/HTTPParsedFields.swift index 33ff1c0..cd4306c 100644 --- a/Sources/HTTPTypes/HTTPParsedFields.swift +++ b/Sources/HTTPTypes/HTTPParsedFields.swift @@ -12,6 +12,8 @@ // //===----------------------------------------------------------------------===// +#if !hasFeature(Embedded) + struct HTTPParsedFields { private var method: ISOLatin1String? private var scheme: ISOLatin1String? @@ -234,3 +236,5 @@ extension HTTPFields { self = try parsedFields.trailerFields } } + +#endif diff --git a/Sources/HTTPTypes/HTTPRequest+URL.swift b/Sources/HTTPTypes/HTTPRequest+URL.swift index 502763a..7c2bc80 100644 --- a/Sources/HTTPTypes/HTTPRequest+URL.swift +++ b/Sources/HTTPTypes/HTTPRequest+URL.swift @@ -12,6 +12,8 @@ // //===----------------------------------------------------------------------===// +#if !hasFeature(Embedded) + #if canImport(FoundationEssentials) import FoundationEssentials #else // canImport(FoundationEssentials) @@ -214,3 +216,5 @@ extension URL { #endif // !canImport(FoundationEssentials) && canImport(CoreFoundation) } } + +#endif diff --git a/Sources/HTTPTypes/HTTPRequest.swift b/Sources/HTTPTypes/HTTPRequest.swift index cf70159..a8e3dbd 100644 --- a/Sources/HTTPTypes/HTTPRequest.swift +++ b/Sources/HTTPTypes/HTTPRequest.swift @@ -332,6 +332,8 @@ extension HTTPRequest: CustomDebugStringConvertible { } } +#if !hasFeature(Embedded) + extension HTTPRequest.PseudoHeaderFields: Codable { public func encode(to encoder: Encoder) throws { var container = encoder.unkeyedContainer() @@ -450,6 +452,8 @@ extension HTTPRequest: Codable { } } +#endif + extension HTTPRequest.Method { /// GET /// diff --git a/Sources/HTTPTypes/HTTPResponse.swift b/Sources/HTTPTypes/HTTPResponse.swift index 30b79cc..a41c58e 100644 --- a/Sources/HTTPTypes/HTTPResponse.swift +++ b/Sources/HTTPTypes/HTTPResponse.swift @@ -263,6 +263,8 @@ extension HTTPResponse: CustomDebugStringConvertible { } } +#if !hasFeature(Embedded) + extension HTTPResponse.PseudoHeaderFields: Codable { public func encode(to encoder: Encoder) throws { var container = encoder.unkeyedContainer() @@ -338,6 +340,8 @@ extension HTTPResponse: Codable { } } +#endif + extension HTTPResponse.Status { // MARK: 1xx From 61922979db63820bec28967a2dda12c4eaf2a876 Mon Sep 17 00:00:00 2001 From: Guoye Zhang Date: Wed, 8 Apr 2026 15:50:36 -0700 Subject: [PATCH 02/10] Typed throws --- Sources/HTTPTypes/HTTPField.swift | 6 +++--- Sources/HTTPTypes/HTTPFields.swift | 8 ++++---- Sources/HTTPTypes/ISOLatin1String.swift | 16 ++++++++++------ Sources/HTTPTypes/NIOLock.swift | 8 ++++---- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/Sources/HTTPTypes/HTTPField.swift b/Sources/HTTPTypes/HTTPField.swift index e7601bc..7181ced 100644 --- a/Sources/HTTPTypes/HTTPField.swift +++ b/Sources/HTTPTypes/HTTPField.swift @@ -112,9 +112,9 @@ public struct HTTPField: Sendable, Hashable { /// /// - Parameter body: The closure to be invoked with the buffer. /// - Returns: Result of the `body` closure. - public func withUnsafeBytesOfValue( - _ body: (UnsafeBufferPointer) throws -> Result - ) rethrows -> Result { + public func withUnsafeBytesOfValue( + _ body: (UnsafeBufferPointer) throws(Failure) -> Result + ) throws(Failure) -> Result { try self.rawValue.withUnsafeBytes(body) } diff --git a/Sources/HTTPTypes/HTTPFields.swift b/Sources/HTTPTypes/HTTPFields.swift index 97a0b47..56312a1 100644 --- a/Sources/HTTPTypes/HTTPFields.swift +++ b/Sources/HTTPTypes/HTTPFields.swift @@ -31,11 +31,11 @@ public struct HTTPFields: Sendable, Hashable { } #if !hasFeature(Embedded) - func withLock(_ body: () throws -> Result) rethrows -> Result { + func withLock(_ body: () throws(Failure) -> Result) throws(Failure) -> Result { fatalError() } #else - final func withLock(_ body: () throws -> Result) rethrows -> Result { + final func withLock(_ body: () throws(Failure) -> Result) throws(Failure) -> Result { try body() } #endif @@ -118,7 +118,7 @@ public struct HTTPFields: Sendable, Hashable { private final class _StorageWithMutex: _Storage, @unchecked Sendable { let mutex = Mutex(()) - override func withLock(_ body: () throws -> Result) rethrows -> Result { + override func withLock(_ body: () throws(Failure) -> Result) throws(Failure) -> Result { try self.mutex.withLock { _ in try body() } @@ -129,7 +129,7 @@ public struct HTTPFields: Sendable, Hashable { private final class _StorageWithNIOLock: _Storage, @unchecked Sendable { let lock = LockStorage.create(value: ()) - override func withLock(_ body: () throws -> Result) rethrows -> Result { + override func withLock(_ body: () throws(Failure) -> Result) throws(Failure) -> Result { try self.lock.withLockedValue { _ in try body() } diff --git a/Sources/HTTPTypes/ISOLatin1String.swift b/Sources/HTTPTypes/ISOLatin1String.swift index a5c08f7..edc2ea5 100644 --- a/Sources/HTTPTypes/ISOLatin1String.swift +++ b/Sources/HTTPTypes/ISOLatin1String.swift @@ -28,10 +28,10 @@ struct ISOLatin1String: Sendable, Hashable { return string } - private func withISOLatin1BytesSlowPath( - _ body: (UnsafeBufferPointer) throws -> Result - ) rethrows -> Result { - try withUnsafeTemporaryAllocation(of: UInt8.self, capacity: self._storage.unicodeScalars.count) { buffer in + private func withISOLatin1BytesSlowPath( + _ body: (UnsafeBufferPointer) throws(Failure) -> Result + ) throws(Failure) -> Result { + try withUnsafeTemporaryAllocation(of: UInt8.self, capacity: self._storage.unicodeScalars.count) { buffer throws(Failure) in for (index, scalar) in self._storage.unicodeScalars.enumerated() { assert(scalar.value <= UInt8.max) buffer[index] = UInt8(truncatingIfNeeded: scalar.value) @@ -71,10 +71,14 @@ struct ISOLatin1String: Sendable, Hashable { } } - func withUnsafeBytes(_ body: (UnsafeBufferPointer) throws -> Result) rethrows -> Result { + func withUnsafeBytes(_ body: (UnsafeBufferPointer) throws(Failure) -> Return) throws(Failure) -> Return { if self._storage.isASCII { var string = self._storage - return try string.withUTF8(body) + return try string.withUTF8 { buffer in + Result { () throws(Failure) in + try body(buffer) + } + }.get() } else { return try self.withISOLatin1BytesSlowPath(body) } diff --git a/Sources/HTTPTypes/NIOLock.swift b/Sources/HTTPTypes/NIOLock.swift index 1df5fd7..198ca97 100644 --- a/Sources/HTTPTypes/NIOLock.swift +++ b/Sources/HTTPTypes/NIOLock.swift @@ -176,14 +176,14 @@ final class LockStorage: ManagedBuffer { } } - func withLockPrimitive(_ body: (UnsafeMutablePointer) throws -> T) rethrows -> T { - try self.withUnsafeMutablePointerToElements { lockPtr in + func withLockPrimitive(_ body: (UnsafeMutablePointer) throws(E) -> T) throws(E) -> T { + try self.withUnsafeMutablePointerToElements { lockPtr throws(E) in try body(lockPtr) } } - func withLockedValue(_ mutate: (inout Value) throws -> T) rethrows -> T { - try self.withUnsafeMutablePointers { valuePtr, lockPtr in + func withLockedValue(_ mutate: (inout Value) throws(E) -> T) throws(E) -> T { + try self.withUnsafeMutablePointers { valuePtr, lockPtr throws(E) in LockOperations.lock(lockPtr) defer { LockOperations.unlock(lockPtr) } return try mutate(&valuePtr.pointee) From 78cd83e7bbdedcc37869d56f96301cb323b45a94 Mon Sep 17 00:00:00 2001 From: Guoye Zhang Date: Wed, 8 Apr 2026 16:18:06 -0700 Subject: [PATCH 03/10] Fix build --- Sources/HTTPTypes/HTTPFields.swift | 4 ++-- Sources/HTTPTypes/ISOLatin1String.swift | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/Sources/HTTPTypes/HTTPFields.swift b/Sources/HTTPTypes/HTTPFields.swift index 56312a1..14f55a0 100644 --- a/Sources/HTTPTypes/HTTPFields.swift +++ b/Sources/HTTPTypes/HTTPFields.swift @@ -119,7 +119,7 @@ public struct HTTPFields: Sendable, Hashable { let mutex = Mutex(()) override func withLock(_ body: () throws(Failure) -> Result) throws(Failure) -> Result { - try self.mutex.withLock { _ in + try self.mutex.withLock { _ throws(Failure) in try body() } } @@ -130,7 +130,7 @@ public struct HTTPFields: Sendable, Hashable { let lock = LockStorage.create(value: ()) override func withLock(_ body: () throws(Failure) -> Result) throws(Failure) -> Result { - try self.lock.withLockedValue { _ in + try self.lock.withLockedValue { _ throws(Failure) in try body() } } diff --git a/Sources/HTTPTypes/ISOLatin1String.swift b/Sources/HTTPTypes/ISOLatin1String.swift index edc2ea5..6e5606d 100644 --- a/Sources/HTTPTypes/ISOLatin1String.swift +++ b/Sources/HTTPTypes/ISOLatin1String.swift @@ -28,16 +28,18 @@ struct ISOLatin1String: Sendable, Hashable { return string } - private func withISOLatin1BytesSlowPath( - _ body: (UnsafeBufferPointer) throws(Failure) -> Result - ) throws(Failure) -> Result { - try withUnsafeTemporaryAllocation(of: UInt8.self, capacity: self._storage.unicodeScalars.count) { buffer throws(Failure) in + private func withISOLatin1BytesSlowPath( + _ body: (UnsafeBufferPointer) throws(Failure) -> Return + ) throws(Failure) -> Return { + try withUnsafeTemporaryAllocation(of: UInt8.self, capacity: self._storage.unicodeScalars.count) { buffer in for (index, scalar) in self._storage.unicodeScalars.enumerated() { assert(scalar.value <= UInt8.max) buffer[index] = UInt8(truncatingIfNeeded: scalar.value) } - return try body(UnsafeBufferPointer(buffer)) - } + return Result { () throws(Failure) in + try body(UnsafeBufferPointer(buffer)) + } + }.get() } init(_ string: String) { From 6f1eddaf8ccceae93746abcf55aa742109d0fd17 Mon Sep 17 00:00:00 2001 From: Guoye Zhang Date: Wed, 8 Apr 2026 16:21:45 -0700 Subject: [PATCH 04/10] Format --- Sources/HTTPTypes/ISOLatin1String.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/HTTPTypes/ISOLatin1String.swift b/Sources/HTTPTypes/ISOLatin1String.swift index 6e5606d..592aaac 100644 --- a/Sources/HTTPTypes/ISOLatin1String.swift +++ b/Sources/HTTPTypes/ISOLatin1String.swift @@ -73,7 +73,9 @@ struct ISOLatin1String: Sendable, Hashable { } } - func withUnsafeBytes(_ body: (UnsafeBufferPointer) throws(Failure) -> Return) throws(Failure) -> Return { + func withUnsafeBytes( + _ body: (UnsafeBufferPointer) throws(Failure) -> Return + ) throws(Failure) -> Return { if self._storage.isASCII { var string = self._storage return try string.withUTF8 { buffer in From 2a2fecd8c97b7bb00b69c33a3897950d31f3529b Mon Sep 17 00:00:00 2001 From: Guoye Zhang Date: Mon, 13 Apr 2026 14:47:54 -0700 Subject: [PATCH 05/10] Add CI --- .github/workflows/pull_request.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 82e0b4a..1a92e5e 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -58,6 +58,12 @@ jobs: runner_pool: general build_scheme: swift-http-types-Package + wasm-sdk: + name: WebAssembly Swift SDK + uses: apple/swift-nio/.github/workflows/wasm_swift_sdk.yml@main + with: + additional_command_arguments: "--target HTTPTypes" + release-builds: name: Release builds uses: apple/swift-nio/.github/workflows/release_builds.yml@main From fbaa44d737f40c07e4f2c1808288a72db050091d Mon Sep 17 00:00:00 2001 From: Guoye Zhang Date: Mon, 13 Apr 2026 16:15:13 -0700 Subject: [PATCH 06/10] Switch to swiftlang workflows --- .github/workflows/pull_request.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 1a92e5e..13a2a7c 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -58,11 +58,16 @@ jobs: runner_pool: general build_scheme: swift-http-types-Package - wasm-sdk: - name: WebAssembly Swift SDK - uses: apple/swift-nio/.github/workflows/wasm_swift_sdk.yml@main + embedded-swift: + name: Build with Embedded Swift + uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@0.0.10 with: - additional_command_arguments: "--target HTTPTypes" + enable_linux_checks: true + enable_macos_checks: true + enable_windows_checks: true + enable_wasm_sdk_build: true + enable_embedded_wasm_sdk_build: true + swift_flags: --target HTTPTypes release-builds: name: Release builds From d74cfa3390326bfc6893544381f534d807a16c44 Mon Sep 17 00:00:00 2001 From: Guoye Zhang Date: Mon, 13 Apr 2026 16:40:34 -0700 Subject: [PATCH 07/10] Downgrade to 0.0.9 --- .github/workflows/pull_request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 13a2a7c..bf86032 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -60,7 +60,7 @@ jobs: embedded-swift: name: Build with Embedded Swift - uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@0.0.10 + uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@0.0.9 with: enable_linux_checks: true enable_macos_checks: true From d141885abb75a2337b7f510c6fd74a33884acae9 Mon Sep 17 00:00:00 2001 From: Guoye Zhang Date: Mon, 13 Apr 2026 17:57:10 -0700 Subject: [PATCH 08/10] Disable other platforms --- .github/workflows/pull_request.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index bf86032..95336d4 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -62,9 +62,9 @@ jobs: name: Build with Embedded Swift uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@0.0.9 with: - enable_linux_checks: true - enable_macos_checks: true - enable_windows_checks: true + enable_linux_checks: false + enable_macos_checks: false + enable_windows_checks: false enable_wasm_sdk_build: true enable_embedded_wasm_sdk_build: true swift_flags: --target HTTPTypes From 94c8f86afd9f9f21da278b23a389fa4849b2b62d Mon Sep 17 00:00:00 2001 From: Guoye Zhang Date: Wed, 15 Apr 2026 12:30:26 -0700 Subject: [PATCH 09/10] Add Mutex for WASI --- Sources/HTTPTypes/HTTPFields.swift | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/Sources/HTTPTypes/HTTPFields.swift b/Sources/HTTPTypes/HTTPFields.swift index 14f55a0..0a3f852 100644 --- a/Sources/HTTPTypes/HTTPFields.swift +++ b/Sources/HTTPTypes/HTTPFields.swift @@ -30,13 +30,24 @@ public struct HTTPFields: Sendable, Hashable { required init() { } - #if !hasFeature(Embedded) + #if canImport(Darwin) && !hasFeature(Embedded) func withLock(_ body: () throws(Failure) -> Result) throws(Failure) -> Result { fatalError() } #else + #if !hasFeature(Embedded) || os(WASI) + let mutex = Mutex(()) + #endif + final func withLock(_ body: () throws(Failure) -> Result) throws(Failure) -> Result { + #if !hasFeature(Embedded) || os(WASI) + try self.mutex.withLock { _ throws(Failure) in + try body() + } + #else + // No Mutex try body() + #endif } #endif @@ -113,7 +124,7 @@ public struct HTTPFields: Sendable, Hashable { } } - #if !hasFeature(Embedded) + #if canImport(Darwin) && !hasFeature(Embedded) @available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) private final class _StorageWithMutex: _Storage, @unchecked Sendable { let mutex = Mutex(()) @@ -125,7 +136,6 @@ public struct HTTPFields: Sendable, Hashable { } } - #if canImport(Darwin) private final class _StorageWithNIOLock: _Storage, @unchecked Sendable { let lock = LockStorage.create(value: ()) @@ -136,19 +146,16 @@ public struct HTTPFields: Sendable, Hashable { } } #endif - #endif private var _storage = { - #if hasFeature(Embedded) - _Storage() - #elseif canImport(Darwin) + #if canImport(Darwin) && !hasFeature(Embedded) if #available(macOS 15.0, iOS 18.0, watchOS 11.0, tvOS 18.0, visionOS 2.0, *) { _StorageWithMutex() } else { _StorageWithNIOLock() } #else - _StorageWithMutex() + _Storage() #endif }() From c7b8528b463aa90bf705815c3aa464081f6251f8 Mon Sep 17 00:00:00 2001 From: Guoye Zhang Date: Wed, 15 Apr 2026 16:08:52 -0700 Subject: [PATCH 10/10] Add version check --- Sources/HTTPTypes/HTTPFields.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/HTTPTypes/HTTPFields.swift b/Sources/HTTPTypes/HTTPFields.swift index 0a3f852..8f14a4b 100644 --- a/Sources/HTTPTypes/HTTPFields.swift +++ b/Sources/HTTPTypes/HTTPFields.swift @@ -35,17 +35,17 @@ public struct HTTPFields: Sendable, Hashable { fatalError() } #else - #if !hasFeature(Embedded) || os(WASI) + #if !hasFeature(Embedded) || (os(WASI) && compiler(>=6.4)) let mutex = Mutex(()) #endif final func withLock(_ body: () throws(Failure) -> Result) throws(Failure) -> Result { - #if !hasFeature(Embedded) || os(WASI) + #if !hasFeature(Embedded) || (os(WASI) && compiler(>=6.4)) try self.mutex.withLock { _ throws(Failure) in try body() } #else - // No Mutex + // Mutex not available try body() #endif }