Skip to content
This repository was archived by the owner on Oct 18, 2023. It is now read-only.

Commit 216613c

Browse files
chenzhaoyudeanberris
authored andcommitted
fix http client timeout (cpp-netlib#763)
1 parent 092cd57 commit 216613c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

boost/network/protocol/http/client/connection/async_normal.hpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -177,19 +177,19 @@ struct http_async_connection
177177
std::uint16_t source_port = request.source_port();
178178

179179
auto self = this->shared_from_this();
180+
if (timeout_ > 0) {
181+
timer_.expires_from_now(std::chrono::seconds(timeout_));
182+
timer_.async_wait(request_strand_.wrap([=] (boost::system::error_code const &ec) {
183+
self->handle_timeout(ec);
184+
}));
185+
}
180186
resolve_(resolver_, host_, port_,
181187
request_strand_.wrap(
182188
[=] (boost::system::error_code const &ec,
183189
resolver_iterator_pair endpoint_range) {
184190
self->handle_resolved(host_, port_, source_port, get_body,
185191
callback, generator, ec, endpoint_range);
186192
}));
187-
if (timeout_ > 0) {
188-
timer_.expires_from_now(std::chrono::seconds(timeout_));
189-
timer_.async_wait(request_strand_.wrap([=] (boost::system::error_code const &ec) {
190-
self->handle_timeout(ec);
191-
}));
192-
}
193193
return response_;
194194
}
195195

0 commit comments

Comments
 (0)