Skip to content

Commit 782b1bf

Browse files
authored
Merge pull request #41 from MaxDesiatov/maxd/fix-wasi-builds
Fix package not building for WASI
2 parents 1827dc9 + a114507 commit 782b1bf

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

Sources/HTTPTypes/HTTPFields.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@
1414

1515
#if canImport(os.lock)
1616
import os.lock
17-
#else
17+
#elseif canImport(Glibc)
1818
import Glibc
19+
#elseif canImport(WASILibc)
20+
import WASILibc
1921
#endif
2022

2123
/// A collection of HTTP fields. It is used in `HTTPRequest` and `HTTPResponse`, and can also be

Sources/HTTPTypesFoundation/URLRequest+HTTPTypes.swift

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import HTTPTypes
1818
import FoundationNetworking
1919
#endif
2020

21+
#if !os(WASI)
22+
2123
extension URLRequest {
2224
/// Create a `URLRequest` from an `HTTPRequest`.
2325
/// - Parameter httpRequest: The HTTP request to convert from.
@@ -63,3 +65,5 @@ extension URLRequest {
6365
return request
6466
}
6567
}
68+
69+
#endif

Sources/HTTPTypesFoundation/URLResponse+HTTPTypes.swift

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import HTTPTypes
1818
import FoundationNetworking
1919
#endif
2020

21+
#if !os(WASI)
22+
2123
extension HTTPURLResponse {
2224
/// Create an `HTTPURLResponse` from an `HTTPResponse`.
2325
/// - Parameter httpResponse: The HTTP response to convert from.
@@ -55,3 +57,5 @@ extension HTTPURLResponse {
5557
return response
5658
}
5759
}
60+
61+
#endif

Sources/HTTPTypesFoundation/URLSession+HTTPTypes.swift

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import HTTPTypes
1818
import FoundationNetworking
1919
#endif
2020

21+
#if !os(WASI)
22+
2123
extension URLSessionTask {
2224
/// The original HTTP request this task was created with.
2325
public var originalHTTPRequest: HTTPRequest? {
@@ -40,6 +42,8 @@ private enum HTTPTypeConversionError: Error {
4042
case failedToConvertURLResponseToHTTPResponse
4143
}
4244

45+
#endif
46+
4347
#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS)
4448

4549
@available(macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0, *)

0 commit comments

Comments
 (0)