@@ -53,8 +53,7 @@ public final class HTTPClientCopyingDelegate: HTTPClientResponseDelegate {
53
53
}
54
54
55
55
extension ClientBootstrap {
56
- fileprivate static func makeBootstrap(
57
- on eventLoop: EventLoop ,
56
+ fileprivate func makeClientTCPBootstrap(
58
57
host: String ,
59
58
requiresTLS: Bool ,
60
59
configuration: HTTPClient . Configuration
@@ -63,7 +62,7 @@ extension ClientBootstrap {
63
62
let sslContext = try NIOSSLContext ( configuration: tlsConfiguration)
64
63
let hostname = ( !requiresTLS || host. isIPAddress) ? nil : host
65
64
let tlsProvider = try NIOSSLClientTLSProvider < ClientBootstrap > ( context: sslContext, serverHostname: hostname)
66
- return NIOClientTCPBootstrap ( ClientBootstrap ( group : eventLoop ) , tls: tlsProvider)
65
+ return NIOClientTCPBootstrap ( self , tls: tlsProvider)
67
66
}
68
67
}
69
68
@@ -79,10 +78,11 @@ extension NIOClientTCPBootstrap {
79
78
let bootstrap : NIOClientTCPBootstrap
80
79
#if canImport(Network)
81
80
// 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) {
85
83
84
+ tsBootstrap = tsBootstrap. channelOption ( NIOTSChannelOptions . waitForActivity, value: false )
85
+ let tlsConfiguration = configuration. tlsConfiguration ?? TLSConfiguration . forClient ( )
86
86
// if we have a proxy and require TLS then use NIOSSL tls support
87
87
if configuration. proxy != nil , requiresTLS {
88
88
let sslContext = try NIOSSLContext ( configuration: tlsConfiguration)
@@ -94,13 +94,19 @@ extension NIOClientTCPBootstrap {
94
94
let tlsProvider = NIOTSClientTLSProvider ( tlsOptions: parameters)
95
95
bootstrap = NIOClientTCPBootstrap ( tsBootstrap, tls: tlsProvider)
96
96
}
97
+ } else if let clientBootstrap = ClientBootstrap ( validatingGroup: eventLoop) {
98
+ bootstrap = try clientBootstrap. makeClientTCPBootstrap ( host: host, requiresTLS: requiresTLS, configuration: configuration)
97
99
} else {
98
- bootstrap = try ClientBootstrap . makeBootstrap ( on : eventLoop , host : host , requiresTLS : requiresTLS , configuration : configuration )
100
+ preconditionFailure ( " Cannot create bootstrap for the supplied EventLoop " )
99
101
}
100
102
#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
+ }
102
108
#endif
103
-
109
+
104
110
// don't enable TLS if we have a proxy, this will be enabled later on
105
111
if requiresTLS, configuration. proxy == nil {
106
112
return bootstrap. enableTLS ( )
0 commit comments