swift-openapi-async-http-client icon indicating copy to clipboard operation
swift-openapi-async-http-client copied to clipboard

Use `HTTPClient.shared` as default

Open MahdiBM opened this issue 1 year ago • 3 comments

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.

MahdiBM avatar Apr 12 '24 06:04 MahdiBM

@swift-server-bot test this please

czechboy0 avatar Apr 12 '24 07:04 czechboy0

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

czechboy0 avatar Apr 15 '24 10:04 czechboy0

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.

MahdiBM avatar Apr 20 '24 21:04 MahdiBM

Seems like this was done in another PR

MahdiBM avatar Oct 07 '24 16:10 MahdiBM