Skip to content

Commit 101f8b9

Browse files
committed
Code review
1 parent b2c371e commit 101f8b9

File tree

1 file changed

+7
-12
lines changed

1 file changed

+7
-12
lines changed

Sources/AsyncHTTPClient/ConnectionPool/ChannelHandler/HTTP1ProxyConnectHandler.swift

+7-12
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ final class HTTP1ProxyConnectHandler: ChannelDuplexHandler, RemovableChannelHand
3535

3636
private var state: State = .initialized
3737

38-
let targetHost: String
39-
let targetPort: Int
40-
let proxyAuthorization: HTTPClient.Authorization?
41-
let deadline: NIODeadline
38+
private let targetHost: String
39+
private let targetPort: Int
40+
private let proxyAuthorization: HTTPClient.Authorization?
41+
private let deadline: NIODeadline
4242

4343
private var proxyEstablishedPromise: EventLoopPromise<Void>?
4444
var proxyEstablishedFuture: EventLoopFuture<Void>? {
@@ -58,9 +58,7 @@ final class HTTP1ProxyConnectHandler: ChannelDuplexHandler, RemovableChannelHand
5858
func handlerAdded(context: ChannelHandlerContext) {
5959
self.proxyEstablishedPromise = context.eventLoop.makePromise(of: Void.self)
6060

61-
if context.channel.isActive {
62-
self.sendConnect(context: context)
63-
}
61+
self.sendConnect(context: context)
6462
}
6563

6664
func handlerRemoved(context: ChannelHandlerContext) {
@@ -88,9 +86,7 @@ final class HTTP1ProxyConnectHandler: ChannelDuplexHandler, RemovableChannelHand
8886
self.state = .failed(error)
8987
self.proxyEstablishedPromise?.fail(error)
9088
context.fireErrorCaught(error)
91-
case .failed:
92-
break
93-
case .completed:
89+
case .failed, .completed:
9490
break
9591
}
9692
}
@@ -174,8 +170,7 @@ final class HTTP1ProxyConnectHandler: ChannelDuplexHandler, RemovableChannelHand
174170
case .initialized:
175171
preconditionFailure("How can we have a scheduled timeout, if the connection is not even up?")
176172

177-
case .connectSent(let scheduled), .headReceived(let scheduled):
178-
scheduled.cancel()
173+
case .connectSent, .headReceived:
179174
let error = HTTPClientError.httpProxyHandshakeTimeout
180175
self.state = .failed(error)
181176
self.proxyEstablishedPromise?.fail(error)

0 commit comments

Comments
 (0)