Skip to content

Commit 1b08850

Browse files
committed
First round of reviews
1 parent b9e6497 commit 1b08850

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

Diff for: Sources/AsyncHTTPClient/ConnectionPool.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ class HTTP1ConnectionProvider {
243243

244244
self.factory = HTTPConnectionPool.ConnectionFactory(
245245
key: self.key,
246-
tlsConfiguration: tlsConfiguration ?? configuration.tlsConfiguration ?? .forClient(),
246+
tlsConfiguration: tlsConfiguration,
247247
clientConfiguration: self.configuration,
248248
sslContextCache: sslContextCache
249249
)
@@ -455,7 +455,7 @@ class HTTP1ConnectionProvider {
455455
logger: Logger) -> EventLoopFuture<Channel> {
456456
let connectionID = HTTPConnectionPool.Connection.ID.globalGenerator.next()
457457
let eventLoop = preference.bestEventLoop ?? self.eventLoop
458-
return self.factory.makeBestChannel(connectionID: connectionID, eventLoop: eventLoop, logger: logger).flatMapThrowing {
458+
return self.factory.makeChannel(connectionID: connectionID, eventLoop: eventLoop, logger: logger).flatMapThrowing {
459459
(channel, _) -> Channel in
460460

461461
// add the http1.1 channel handlers

Diff for: Sources/AsyncHTTPClient/ConnectionPool/HTTPConnectionPool+Factory.swift

+4-6
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ extension HTTPConnectionPool {
4747
}
4848

4949
extension HTTPConnectionPool.ConnectionFactory {
50-
func makeBestChannel(connectionID: HTTPConnectionPool.Connection.ID, eventLoop: EventLoop, logger: Logger) -> EventLoopFuture<(Channel, HTTPVersion)> {
51-
50+
func makeChannel(connectionID: HTTPConnectionPool.Connection.ID, eventLoop: EventLoop, logger: Logger) -> EventLoopFuture<(Channel, HTTPVersion)> {
5251
if self.key.scheme.isProxyable, let proxy = self.clientConfiguration.proxy {
5352
switch proxy.type {
5453
case .socks:
@@ -57,11 +56,11 @@ extension HTTPConnectionPool.ConnectionFactory {
5756
return self.makeHTTPProxyChannel(proxy, connectionID: connectionID, eventLoop: eventLoop, logger: logger)
5857
}
5958
} else {
60-
return self.makeChannel(eventLoop: eventLoop, logger: logger)
59+
return self.makeNonProxiedChannel(eventLoop: eventLoop, logger: logger)
6160
}
6261
}
6362

64-
private func makeChannel(eventLoop: EventLoop, logger: Logger) -> EventLoopFuture<(Channel, HTTPVersion)> {
63+
private func makeNonProxiedChannel(eventLoop: EventLoop, logger: Logger) -> EventLoopFuture<(Channel, HTTPVersion)> {
6564
switch self.key.scheme {
6665
case .http, .http_unix, .unix:
6766
return self.makePlainChannel(eventLoop: eventLoop).map { ($0, .http1_1) }
@@ -301,9 +300,8 @@ extension HTTPConnectionPool.ConnectionFactory {
301300
.addTimeoutIfNeeded(self.clientConfiguration.timeout)
302301
.channelInitializer { channel in
303302
sslContextFuture.flatMap { (sslContext) -> EventLoopFuture<Void> in
304-
let sync = channel.pipeline.syncOperations
305-
306303
do {
304+
let sync = channel.pipeline.syncOperations
307305
let sslHandler = try NIOSSLClientHandler(
308306
context: sslContext,
309307
serverHostname: hostname

Diff for: Tests/AsyncHTTPClientTests/HTTP1ProxyConnectHandlerTests.swift

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class HTTP1ProxyConnectHandlerTests: XCTestCase {
2222
let embedded = EmbeddedChannel()
2323
defer { XCTAssertNoThrow(try embedded.finish(acceptAlreadyClosed: false)) }
2424

25-
let socketAddress = try! SocketAddress(ipAddress: "127.0.0.1", port: 3000)
25+
let socketAddress = try! SocketAddress.makeAddressResolvingHost("localhost", port: 3000)
2626
XCTAssertNoThrow(try embedded.connect(to: socketAddress).wait())
2727

2828
let connectPromise = embedded.eventLoop.makePromise(of: Void.self)
@@ -57,7 +57,7 @@ class HTTP1ProxyConnectHandlerTests: XCTestCase {
5757
func testProxyConnectWithAuthorization() {
5858
let embedded = EmbeddedChannel()
5959

60-
let socketAddress = try! SocketAddress(ipAddress: "127.0.0.1", port: 3000)
60+
let socketAddress = try! SocketAddress.makeAddressResolvingHost("localhost", port: 3000)
6161
XCTAssertNoThrow(try embedded.connect(to: socketAddress).wait())
6262

6363
let connectPromise = embedded.eventLoop.makePromise(of: Void.self)
@@ -92,7 +92,7 @@ class HTTP1ProxyConnectHandlerTests: XCTestCase {
9292
func testProxyConnectWithoutAuthorizationFailure500() {
9393
let embedded = EmbeddedChannel()
9494

95-
let socketAddress = try! SocketAddress(ipAddress: "127.0.0.1", port: 3000)
95+
let socketAddress = try! SocketAddress.makeAddressResolvingHost("localhost", port: 3000)
9696
XCTAssertNoThrow(try embedded.connect(to: socketAddress).wait())
9797

9898
let connectPromise = embedded.eventLoop.makePromise(of: Void.self)
@@ -130,7 +130,7 @@ class HTTP1ProxyConnectHandlerTests: XCTestCase {
130130
func testProxyConnectWithoutAuthorizationButAuthorizationNeeded() {
131131
let embedded = EmbeddedChannel()
132132

133-
let socketAddress = try! SocketAddress(ipAddress: "127.0.0.1", port: 3000)
133+
let socketAddress = try! SocketAddress.makeAddressResolvingHost("localhost", port: 3000)
134134
XCTAssertNoThrow(try embedded.connect(to: socketAddress).wait())
135135

136136
let connectPromise = embedded.eventLoop.makePromise(of: Void.self)
@@ -168,7 +168,7 @@ class HTTP1ProxyConnectHandlerTests: XCTestCase {
168168
func testProxyConnectReceivesBody() {
169169
let embedded = EmbeddedChannel()
170170

171-
let socketAddress = try! SocketAddress(ipAddress: "127.0.0.1", port: 3000)
171+
let socketAddress = try! SocketAddress.makeAddressResolvingHost("localhost", port: 3000)
172172
XCTAssertNoThrow(try embedded.connect(to: socketAddress).wait())
173173

174174
let connectPromise = embedded.eventLoop.makePromise(of: Void.self)

0 commit comments

Comments
 (0)