@@ -21,7 +21,7 @@ import NIOSOCKS
2121import NIOSSL
2222import NIOTLS
2323#if canImport(Network)
24- import NIOTransportServices
24+ import NIOTransportServices
2525#endif
2626
2727extension HTTPConnectionPool {
@@ -341,18 +341,18 @@ extension HTTPConnectionPool.ConnectionFactory {
341341
342342 private func makePlainBootstrap( deadline: NIODeadline , eventLoop: EventLoop ) -> NIOClientTCPBootstrapProtocol {
343343 #if canImport(Network)
344- if #available( OSX 10 . 14 , iOS 12 . 0 , tvOS 12 . 0 , watchOS 6 . 0 , * ) , let tsBootstrap = NIOTSConnectionBootstrap ( validatingGroup: eventLoop) {
345- return tsBootstrap
346- . connectTimeout ( deadline - NIODeadline. now ( ) )
347- . channelInitializer { channel in
348- do {
349- try channel. pipeline. syncOperations. addHandler ( HTTPClient . NWErrorHandler ( ) )
350- return channel. eventLoop. makeSucceededVoidFuture ( )
351- } catch {
352- return channel. eventLoop. makeFailedFuture ( error)
353- }
344+ if #available( OSX 10 . 14 , iOS 12 . 0 , tvOS 12 . 0 , watchOS 6 . 0 , * ) , let tsBootstrap = NIOTSConnectionBootstrap ( validatingGroup: eventLoop) {
345+ return tsBootstrap
346+ . connectTimeout ( deadline - NIODeadline. now ( ) )
347+ . channelInitializer { channel in
348+ do {
349+ try channel. pipeline. syncOperations. addHandler ( HTTPClient . NWErrorHandler ( ) )
350+ return channel. eventLoop. makeSucceededVoidFuture ( )
351+ } catch {
352+ return channel. eventLoop. makeFailedFuture ( error)
354353 }
355- }
354+ }
355+ }
356356 #endif
357357
358358 if let nioBootstrap = ClientBootstrap ( validatingGroup: eventLoop) {
@@ -392,10 +392,10 @@ extension HTTPConnectionPool.ConnectionFactory {
392392 }
393393
394394 #if canImport(Network)
395- // If NIOTransportSecurity is used, we want to map NWErrors into NWPOsixErrors or NWTLSError.
396- channelFuture = channelFuture. flatMapErrorThrowing { error in
397- throw HTTPClient . NWErrorHandler. translateError ( error)
398- }
395+ // If NIOTransportSecurity is used, we want to map NWErrors into NWPOsixErrors or NWTLSError.
396+ channelFuture = channelFuture. flatMapErrorThrowing { error in
397+ throw HTTPClient . NWErrorHandler. translateError ( error)
398+ }
399399 #endif
400400
401401 return channelFuture
@@ -416,29 +416,29 @@ extension HTTPConnectionPool.ConnectionFactory {
416416 }
417417
418418 #if canImport(Network)
419- if #available( OSX 10 . 14 , iOS 12 . 0 , tvOS 12 . 0 , watchOS 6 . 0 , * ) , let tsBootstrap = NIOTSConnectionBootstrap ( validatingGroup: eventLoop) {
420- // create NIOClientTCPBootstrap with NIOTS TLS provider
421- let bootstrapFuture = tlsConfig. getNWProtocolTLSOptions ( on: eventLoop) . map {
422- options -> NIOClientTCPBootstrapProtocol in
423-
424- tsBootstrap
425- . connectTimeout ( deadline - NIODeadline. now ( ) )
426- . tlsOptions ( options)
427- . channelInitializer { channel in
428- do {
429- try channel. pipeline. syncOperations. addHandler ( HTTPClient . NWErrorHandler ( ) )
430- // we don't need to set a TLS deadline for NIOTS connections, since the
431- // TLS handshake is part of the TS connection bootstrap. If the TLS
432- // handshake times out the complete connection creation will be failed.
433- try channel. pipeline. syncOperations. addHandler ( TLSEventsHandler ( deadline: nil ) )
434- return channel. eventLoop. makeSucceededVoidFuture ( )
435- } catch {
436- return channel. eventLoop. makeFailedFuture ( error)
437- }
438- } as NIOClientTCPBootstrapProtocol
439- }
440- return bootstrapFuture
419+ if #available( OSX 10 . 14 , iOS 12 . 0 , tvOS 12 . 0 , watchOS 6 . 0 , * ) , let tsBootstrap = NIOTSConnectionBootstrap ( validatingGroup: eventLoop) {
420+ // create NIOClientTCPBootstrap with NIOTS TLS provider
421+ let bootstrapFuture = tlsConfig. getNWProtocolTLSOptions ( on: eventLoop) . map {
422+ options -> NIOClientTCPBootstrapProtocol in
423+
424+ tsBootstrap
425+ . connectTimeout ( deadline - NIODeadline. now ( ) )
426+ . tlsOptions ( options)
427+ . channelInitializer { channel in
428+ do {
429+ try channel. pipeline. syncOperations. addHandler ( HTTPClient . NWErrorHandler ( ) )
430+ // we don't need to set a TLS deadline for NIOTS connections, since the
431+ // TLS handshake is part of the TS connection bootstrap. If the TLS
432+ // handshake times out the complete connection creation will be failed.
433+ try channel. pipeline. syncOperations. addHandler ( TLSEventsHandler ( deadline: nil ) )
434+ return channel. eventLoop. makeSucceededVoidFuture ( )
435+ } catch {
436+ return channel. eventLoop. makeFailedFuture ( error)
437+ }
438+ } as NIOClientTCPBootstrapProtocol
441439 }
440+ return bootstrapFuture
441+ }
442442 #endif
443443
444444 let host = self . key. host
0 commit comments