@@ -4307,18 +4307,25 @@ final class HTTPClientTests: XCTestCaseHTTPClientTestsBaseClass {
43074307 XCTAssertEqual ( request. headers. first ( name: " Authorization " ) , " Basic Zm9vOmJhcg== " )
43084308 }
43094309
4310- func testHTTP1PlainTextConnectionDebugInitializer ( ) {
4310+ func runBaseTestForHTTP1ConnectionDebugInitializer ( ssl : Bool ) {
43114311 let connectionDebugInitializerUtil = CountingDebugInitializerUtil ( )
43124312
43134313 // Initializing even with just `http1_1ConnectionDebugInitializer` (rather than manually
43144314 // modifying `config`) to ensure that the matching `init` actually wires up this argument
43154315 // with the respective property. This is necessary as these parameters are defaulted and can
43164316 // be easy to miss.
43174317 var config = HTTPClient . Configuration (
4318- http1_1ConnectionDebugInitializer: connectionDebugInitializerUtil. initialize ( channel: )
4318+ http1_1ConnectionDebugInitializer: { channel in
4319+ return connectionDebugInitializerUtil. initialize ( channel: channel)
4320+ }
43194321 )
43204322 config. httpVersion = . http1Only
43214323
4324+ if ssl {
4325+ config. tlsConfiguration = . clientDefault
4326+ config. tlsConfiguration? . certificateVerification = . none
4327+ }
4328+
43224329 let client = HTTPClient (
43234330 eventLoopGroupProvider: . singleton,
43244331 configuration: config,
@@ -4329,52 +4336,26 @@ final class HTTPClientTests: XCTestCaseHTTPClientTestsBaseClass {
43294336 )
43304337 defer { XCTAssertNoThrow ( client. shutdown ( ) ) }
43314338
4332- let bin = HTTPBin ( . http1_1( ssl: false , compress: false ) )
4339+ let bin = HTTPBin ( . http1_1( ssl: ssl , compress: false ) )
43334340 defer { XCTAssertNoThrow ( try bin. shutdown ( ) ) }
43344341
4342+ let scheme = ssl ? " https " : " http "
4343+
43354344 for _ in 0 ..< 3 {
4336- XCTAssertNoThrow ( try client. get ( url: " http ://localhost:\( bin. port) /get " ) . wait ( ) )
4345+ XCTAssertNoThrow ( try client. get ( url: " \( scheme ) ://localhost: \( bin. port) /get " ) . wait ( ) )
43374346 }
43384347
43394348 // Even though multiple requests were made, the connection debug initializer must be called
43404349 // only once.
43414350 XCTAssertEqual ( connectionDebugInitializerUtil. executionCount, 1 )
43424351 }
43434352
4344- func testHTTP1EncryptedConnectionDebugInitializer( ) {
4345- let connectionDebugInitializerUtil = CountingDebugInitializerUtil ( )
4346-
4347- // Initializing even with just `http1_1ConnectionDebugInitializer` (rather than manually
4348- // modifying `config`) to ensure that the matching `init` actually wires up this argument
4349- // with the respective property. This is necessary as these parameters are defaulted and can
4350- // be easy to miss.
4351- var config = HTTPClient . Configuration (
4352- http1_1ConnectionDebugInitializer: connectionDebugInitializerUtil. initialize ( channel: )
4353- )
4354- config. tlsConfiguration = . clientDefault
4355- config. tlsConfiguration? . certificateVerification = . none
4356- config. httpVersion = . http1Only
4357-
4358- let client = HTTPClient (
4359- eventLoopGroupProvider: . singleton,
4360- configuration: config,
4361- backgroundActivityLogger: Logger (
4362- label: " HTTPClient " ,
4363- factory: StreamLogHandler . standardOutput ( label: )
4364- )
4365- )
4366- defer { XCTAssertNoThrow ( client. shutdown ( ) ) }
4367-
4368- let bin = HTTPBin ( . http1_1( ssl: true , compress: false ) )
4369- defer { XCTAssertNoThrow ( try bin. shutdown ( ) ) }
4370-
4371- for _ in 0 ..< 3 {
4372- XCTAssertNoThrow ( try client. get ( url: " https://localhost: \( bin. port) /get " ) . wait ( ) )
4373- }
4353+ func testHTTP1PlainTextConnectionDebugInitializer( ) {
4354+ runBaseTestForHTTP1ConnectionDebugInitializer ( ssl: false )
4355+ }
43744356
4375- // Even though multiple requests were made, the connection debug initializer must be called
4376- // only once.
4377- XCTAssertEqual ( connectionDebugInitializerUtil. executionCount, 1 )
4357+ func testHTTP1EncryptedConnectionDebugInitializer( ) {
4358+ runBaseTestForHTTP1ConnectionDebugInitializer ( ssl: true )
43784359 }
43794360
43804361 func testHTTP2ConnectionAndStreamChannelDebugInitializers( ) {
@@ -4386,10 +4367,12 @@ final class HTTPClientTests: XCTestCaseHTTPClientTestsBaseClass {
43864367 // that the matching `init` actually wires up these arguments with the respective
43874368 // properties. This is necessary as these parameters are defaulted and can be easy to miss.
43884369 var config = HTTPClient . Configuration (
4389- http2ConnectionDebugInitializer:
4390- connectionDebugInitializerUtil. initialize ( channel: ) ,
4391- http2StreamChannelDebugInitializer:
4392- streamChannelDebugInitializerUtil. initialize ( channel: )
4370+ http2ConnectionDebugInitializer: { channel in
4371+ return connectionDebugInitializerUtil. initialize ( channel: channel)
4372+ } ,
4373+ http2StreamChannelDebugInitializer: { channel in
4374+ return streamChannelDebugInitializerUtil. initialize ( channel: channel)
4375+ }
43934376 )
43944377 config. tlsConfiguration = . clientDefault
43954378 config. tlsConfiguration? . certificateVerification = . none
@@ -4429,7 +4412,6 @@ final class CountingDebugInitializerUtil: Sendable {
44294412 var executionCount : Int { self . _executionCount. withLockedValue { $0 } }
44304413
44314414 /// The acual debug initializer.
4432- @Sendable
44334415 func initialize( channel: Channel ) -> EventLoopFuture < Void > {
44344416 self . _executionCount. withLockedValue { $0 += 1 }
44354417
0 commit comments