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

Use HTTPClient.shared as default #38

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

MahdiBM
Copy link
Contributor

@MahdiBM MahdiBM commented Apr 12, 2024

Motivation

AHC provides a shared HTTPClient now so we should use that instead of creating our own.

Modifications

Use HTTPClient.shared as the default HTTPClient.

Result

Apps won't be using 2 different shared HTTPClients.

Test Plan

The change does not seem to need test changes.

@czechboy0
Copy link
Collaborator

@swift-server-bot test this please

@czechboy0
Copy link
Collaborator

@MahdiBM the nightly/swift-6 pipeline seems to have failed, can you take a look?

@MahdiBM
Copy link
Contributor Author

MahdiBM commented Apr 20, 2024

Errors:

/code/Sources/OpenAPIAsyncHTTPClient/AsyncHTTPClientTransport.swift:91:14: error: associated value 'invalidRequestURL(request:baseURL:)' of 'Sendable'-conforming enum 'Error' has non-sendable type 'URL'; this is an error in the Swift 6 language mode
 89 | 
 90 |         /// Invalid URL composed from base URL and received request.
 91 |         case invalidRequestURL(request: HTTPRequest, baseURL: URL)
    |              `- error: associated value 'invalidRequestURL(request:baseURL:)' of 'Sendable'-conforming enum 'Error' has non-sendable type 'URL'; this is an error in the Swift 6 language mode
 92 | 
 93 |         // MARK: CustomStringConvertible

Foundation.URL:1:15: note: struct 'URL' does not conform to the 'Sendable' protocol
 1 | public struct URL : ReferenceConvertible, Equatable {
   |               `- note: struct 'URL' does not conform to the 'Sendable' protocol
 2 |     public typealias ReferenceType = NSURL
 3 |     public init?(string: String)
[1095/1105] Compiling OpenAPIAsyncHTTPClient AsyncHTTPClientTransport.swift
/code/Sources/OpenAPIAsyncHTTPClient/AsyncHTTPClientTransport.swift:91:14: error: associated value 'invalidRequestURL(request:baseURL:)' of 'Sendable'-conforming enum 'Error' has non-sendable type 'URL'; this is an error in the Swift 6 language mode
 89 | 
 90 |         /// Invalid URL composed from base URL and received request.
 91 |         case invalidRequestURL(request: HTTPRequest, baseURL: URL)
    |              `- error: associated value 'invalidRequestURL(request:baseURL:)' of 'Sendable'-conforming enum 'Error' has non-sendable type 'URL'; this is an error in the Swift 6 language mode
 92 | 
 93 |         // MARK: CustomStringConvertible

Foundation.URL:1:15: note: struct 'URL' does not conform to the 'Sendable' protocol
 1 | public struct URL : ReferenceConvertible, Equatable {
   |               `- note: struct 'URL' does not conform to the 'Sendable' protocol
 2 |     public typealias ReferenceType = NSURL
 3 |     public init?(string: String)

/code/Sources/OpenAPIAsyncHTTPClient/AsyncHTTPClientTransport.swift:23:17: error: '@preconcurrency' attribute on module 'Foundation' has no effect
 21 | import Foundation
 22 | #else
 23 | @preconcurrency import struct Foundation.URL
    |                 `- error: '@preconcurrency' attribute on module 'Foundation' has no effect
 24 | import struct Foundation.URLComponents
 25 | import struct Foundation.Data

They seem to be unrelated to this PR.
Non-the-less I added a condition to a #if to only apply @preconcurrency when Swift version is less than 6.
I also enabled the strict-concurrency flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants