mirror of
https://github.com/swift-server/async-http-client.git
synced 2026-06-02 07:37:34 +00:00
Accurately apply the connect timeout in async code (#616)
Motivation We should apply the connect timeout to the complete set of connection attempts, rather than the request deadline. This allows users fine-grained control over how long we attempt to connect for. This is also the behaviour of our old-school interface. Modifications - Changed the connect deadline calculation for async/await to match that of the future-based code. - Added a connect timeout test. Result Connect timeouts are properly handled
This commit is contained in:
@@ -134,7 +134,7 @@ extension HTTPClient {
|
||||
request: request,
|
||||
requestOptions: .init(idleReadTimeout: nil),
|
||||
logger: logger,
|
||||
connectionDeadline: deadline,
|
||||
connectionDeadline: .now() + (self.configuration.timeout.connectionCreationTimeout),
|
||||
preferredEventLoop: eventLoop,
|
||||
responseContinuation: continuation
|
||||
)
|
||||
|
||||
@@ -604,7 +604,7 @@ public class HTTPClient {
|
||||
eventLoopPreference: eventLoopPreference,
|
||||
task: task,
|
||||
redirectHandler: redirectHandler,
|
||||
connectionDeadline: .now() + (self.configuration.timeout.connect ?? .seconds(10)),
|
||||
connectionDeadline: .now() + (self.configuration.timeout.connectionCreationTimeout),
|
||||
requestOptions: .fromClientConfiguration(self.configuration),
|
||||
delegate: delegate
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user