@@ -53,8 +53,7 @@ public final class HTTPClientCopyingDelegate: HTTPClientResponseDelegate {
5353}
5454
5555extension ClientBootstrap {
56- fileprivate static func makeBootstrap(
57- on eventLoop: EventLoop ,
56+ fileprivate func makeClientTCPBootstrap(
5857 host: String ,
5958 requiresTLS: Bool ,
6059 configuration: HTTPClient . Configuration
@@ -63,7 +62,7 @@ extension ClientBootstrap {
6362 let sslContext = try NIOSSLContext ( configuration: tlsConfiguration)
6463 let hostname = ( !requiresTLS || host. isIPAddress) ? nil : host
6564 let tlsProvider = try NIOSSLClientTLSProvider < ClientBootstrap > ( context: sslContext, serverHostname: hostname)
66- return NIOClientTCPBootstrap ( ClientBootstrap ( group : eventLoop ) , tls: tlsProvider)
65+ return NIOClientTCPBootstrap ( self , tls: tlsProvider)
6766 }
6867}
6968
@@ -79,10 +78,11 @@ extension NIOClientTCPBootstrap {
7978 let bootstrap : NIOClientTCPBootstrap
8079 #if canImport(Network)
8180 // if eventLoop is compatible with NIOTransportServices create a NIOTSConnectionBootstrap
82- if #available( OSX 10 . 14 , iOS 12 . 0 , tvOS 12 . 0 , watchOS 6 . 0 , * ) , eventLoop is NIOTSEventLoop {
83- let tsBootstrap = NIOTSConnectionBootstrap ( group: eventLoop) . channelOption ( NIOTSChannelOptions . waitForActivity, value: false )
84- let tlsConfiguration = configuration. tlsConfiguration ?? TLSConfiguration . forClient ( )
81+ if #available( OSX 10 . 14 , iOS 12 . 0 , tvOS 12 . 0 , watchOS 6 . 0 , * ) ,
82+ var tsBootstrap = NIOTSConnectionBootstrap ( validatingGroup: eventLoop) {
8583
84+ tsBootstrap = tsBootstrap. channelOption ( NIOTSChannelOptions . waitForActivity, value: false )
85+ let tlsConfiguration = configuration. tlsConfiguration ?? TLSConfiguration . forClient ( )
8686 // if we have a proxy and require TLS then use NIOSSL tls support
8787 if configuration. proxy != nil , requiresTLS {
8888 let sslContext = try NIOSSLContext ( configuration: tlsConfiguration)
@@ -94,13 +94,19 @@ extension NIOClientTCPBootstrap {
9494 let tlsProvider = NIOTSClientTLSProvider ( tlsOptions: parameters)
9595 bootstrap = NIOClientTCPBootstrap ( tsBootstrap, tls: tlsProvider)
9696 }
97+ } else if let clientBootstrap = ClientBootstrap ( validatingGroup: eventLoop) {
98+ bootstrap = try clientBootstrap. makeClientTCPBootstrap ( host: host, requiresTLS: requiresTLS, configuration: configuration)
9799 } else {
98- bootstrap = try ClientBootstrap . makeBootstrap ( on : eventLoop , host : host , requiresTLS : requiresTLS , configuration : configuration )
100+ preconditionFailure ( " Cannot create bootstrap for the supplied EventLoop " )
99101 }
100102 #else
101- bootstrap = try ClientBootstrap . makeBootstrap ( on: eventLoop, host: host, requiresTLS: requiresTLS, configuration: configuration)
103+ if let clientBootstrap = ClientBootstrap ( validatingGroup: eventLoop) {
104+ bootstrap = try clientBootstrap. makeClientTCPBootstrap ( host: host, requiresTLS: requiresTLS, configuration: configuration)
105+ } else {
106+ preconditionFailure ( " Cannot create bootstrap for the supplied EventLoop " )
107+ }
102108 #endif
103-
109+
104110 // don't enable TLS if we have a proxy, this will be enabled later on
105111 if requiresTLS, configuration. proxy == nil {
106112 return bootstrap. enableTLS ( )
0 commit comments