@@ -72,6 +72,7 @@ struct http_async_connection
72
72
connection_delegate_ptr delegate)
73
73
: timeout_(timeout),
74
74
timer_ (resolver.get_io_service()),
75
+ is_timedout_(false ),
75
76
follow_redirect_(follow_redirect),
76
77
resolver_(resolver),
77
78
resolve_(resolve),
@@ -122,6 +123,7 @@ struct http_async_connection
122
123
123
124
void handle_timeout (boost::system::error_codeconst &ec) {
124
125
if (!ec) delegate_->disconnect ();
126
+ is_timedout_ =true ;
125
127
}
126
128
127
129
void handle_resolved (boost::uint16_t port,bool get_body,
@@ -152,7 +154,9 @@ struct http_async_connection
152
154
body_generator_function_type generator,
153
155
resolver_iterator_pair endpoint_range,
154
156
boost::system::error_codeconst & ec) {
155
- if (!ec) {
157
+ if (is_timedout_) {
158
+ set_errors (asio::error::timed_out);
159
+ }else if (!ec) {
156
160
BOOST_ASSERT (delegate_.get () !=0 );
157
161
delegate_->write (
158
162
command_streambuf,
@@ -191,7 +195,7 @@ struct http_async_connection
191
195
body_generator_function_type generator,
192
196
boost::system::error_codeconst & ec,
193
197
std::size_t bytes_transferred) {
194
- if (!ec) {
198
+ if (!is_timedout_ && ! ec) {
195
199
if (generator) {
196
200
// Here we write some more data that the generator provides, before
197
201
// we wait for data from the server.
@@ -219,7 +223,7 @@ struct http_async_connection
219
223
version, get_body, callback, placeholders::error,
220
224
placeholders::bytes_transferred)));
221
225
}else {
222
- set_errors (ec);
226
+ set_errors (is_timedout_ ? asio::error::timed_out : ec);
223
227
}
224
228
}
225
229
@@ -235,7 +239,8 @@ struct http_async_connection
235
239
#else
236
240
false && short_read_error;
237
241
#endif
238
- if (!ec || ec == boost::asio::error::eof || is_ssl_short_read_error) {
242
+ if (!is_timedout_ &&
243
+ (!ec || ec == boost::asio::error::eof || is_ssl_short_read_error)) {
239
244
logic::tribool parsed_ok;
240
245
size_t remainder;
241
246
switch (state) {
@@ -403,7 +408,7 @@ struct http_async_connection
403
408
BOOST_ASSERT (false &&" Bug, report this to the developers!" );
404
409
}
405
410
}else {
406
- boost::system::system_errorerror (ec);
411
+ boost::system::system_errorerror (is_timedout_ ? asio::error::timed_out : ec);
407
412
this ->source_promise .set_exception (boost::copy_exception (error));
408
413
this ->destination_promise .set_exception (boost::copy_exception (error));
409
414
switch (state) {
@@ -454,6 +459,7 @@ struct http_async_connection
454
459
455
460
int timeout_;
456
461
boost::asio::deadline_timer timer_;
462
+ bool is_timedout_;
457
463
bool follow_redirect_;
458
464
resolver_type& resolver_;
459
465
resolve_function resolve_;