Skip to content

Commit 6cfd62c

Browse files
committed
Code review: Code moved.
1 parent b58bc15 commit 6cfd62c

File tree

2 files changed

+33
-19
lines changed

2 files changed

+33
-19
lines changed

Diff for: Sources/AsyncHTTPClient/ConnectionPool.swift

+2-19
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import Logging
1717
import NIO
1818
import NIOConcurrencyHelpers
1919
import NIOHTTP1
20-
import NIOHTTPCompression
2120
import NIOSSL
2221
import NIOTLS
2322
import NIOTransportServices
@@ -456,28 +455,12 @@ class HTTP1ConnectionProvider {
456455
let connectionID = HTTPConnectionPool.Connection.ID.globalGenerator.next()
457456
let eventLoop = preference.bestEventLoop ?? self.eventLoop
458457
let deadline = NIODeadline.now() + (self.configuration.timeout.connect ?? .seconds(10))
459-
return self.factory.makeChannel(
458+
return self.factory.makeHTTP1Channel(
460459
connectionID: connectionID,
461460
deadline: deadline,
462461
eventLoop: eventLoop,
463462
logger: logger
464-
).flatMapThrowing {
465-
(channel, _) -> Channel in
466-
467-
// add the http1.1 channel handlers
468-
let syncOperations = channel.pipeline.syncOperations
469-
try syncOperations.addHTTPClientHandlers(leftOverBytesStrategy: .forwardBytes)
470-
471-
switch self.configuration.decompression {
472-
case .disabled:
473-
()
474-
case .enabled(let limit):
475-
let decompressHandler = NIOHTTPResponseDecompressor(limit: limit)
476-
try syncOperations.addHandler(decompressHandler)
477-
}
478-
479-
return channel
480-
}
463+
)
481464
}
482465

483466
/// A `Waiter` represents a request that waits for a connection when none is

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

+31
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import Logging
1616
import NIO
1717
import NIOHTTP1
18+
import NIOHTTPCompression
1819
import NIOSOCKS
1920
import NIOSSL
2021
import NIOTLS
@@ -47,6 +48,36 @@ extension HTTPConnectionPool {
4748
}
4849

4950
extension HTTPConnectionPool.ConnectionFactory {
51+
func makeHTTP1Channel(
52+
connectionID: HTTPConnectionPool.Connection.ID,
53+
deadline: NIODeadline,
54+
eventLoop: EventLoop,
55+
logger: Logger
56+
) -> EventLoopFuture<Channel> {
57+
self.makeChannel(
58+
connectionID: connectionID,
59+
deadline: deadline,
60+
eventLoop: eventLoop,
61+
logger: logger
62+
).flatMapThrowing {
63+
(channel, _) -> Channel in
64+
65+
// add the http1.1 channel handlers
66+
let syncOperations = channel.pipeline.syncOperations
67+
try syncOperations.addHTTPClientHandlers(leftOverBytesStrategy: .forwardBytes)
68+
69+
switch self.clientConfiguration.decompression {
70+
case .disabled:
71+
()
72+
case .enabled(let limit):
73+
let decompressHandler = NIOHTTPResponseDecompressor(limit: limit)
74+
try syncOperations.addHandler(decompressHandler)
75+
}
76+
77+
return channel
78+
}
79+
}
80+
5081
func makeChannel(
5182
connectionID: HTTPConnectionPool.Connection.ID,
5283
deadline: NIODeadline,

0 commit comments

Comments
 (0)