Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import FoundationEssentials instead of Foundation when available #798

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
//
//===----------------------------------------------------------------------===//

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

@available(macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0, *)
extension HTTPClientRequest {
Expand Down
7 changes: 6 additions & 1 deletion Sources/AsyncHTTPClient/BasicAuth.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@
//
//===----------------------------------------------------------------------===//

import Foundation
import NIOHTTP1

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

/// Generates base64 encoded username + password for http basic auth.
///
/// - Parameters:
Expand Down
4 changes: 4 additions & 0 deletions Sources/AsyncHTTPClient/FoundationExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,11 @@
// Extensions which provide better ergonomics when using Foundation types,
// or by using Foundation APIs.

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

extension HTTPClient.Cookie {
/// The cookie's expiration date.
Expand Down
7 changes: 6 additions & 1 deletion Sources/AsyncHTTPClient/HTTPClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
//===----------------------------------------------------------------------===//

import Atomics
import Foundation
import Logging
import NIOConcurrencyHelpers
import NIOCore
Expand All @@ -24,6 +23,12 @@ import NIOSSL
import NIOTLS
import NIOTransportServices

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

extension Logger {
private func requestInfo(_ request: HTTPClient.Request) -> Logger.Metadata.Value {
"\(request.method) \(request.url)"
Expand Down
7 changes: 6 additions & 1 deletion Sources/AsyncHTTPClient/HTTPHandler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,19 @@
//===----------------------------------------------------------------------===//

import Algorithms
import Foundation
import Logging
import NIOConcurrencyHelpers
import NIOCore
import NIOHTTP1
import NIOPosix
import NIOSSL

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

extension HTTPClient {
/// A request body.
public struct Body {
Expand Down
7 changes: 6 additions & 1 deletion Tests/AsyncHTTPClientTests/HTTPClientCookieTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@

import AsyncHTTPClient
import CAsyncHTTPClient
import Foundation
import XCTest

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

class HTTPClientCookieTests: XCTestCase {
func testCookie() {
let v =
Expand Down
7 changes: 6 additions & 1 deletion Tests/AsyncHTTPClientTests/HTTPClientTestUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
//===----------------------------------------------------------------------===//

import Atomics
import Foundation
import Logging
import NIOConcurrencyHelpers
import NIOCore
Expand All @@ -31,6 +30,12 @@ import XCTest

@testable import AsyncHTTPClient

#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif

#if canImport(xlocale)
import xlocale
#elseif canImport(locale_h)
Expand Down