@@ -72,6 +72,7 @@ struct http_async_connection
7272 connection_delegate_ptr delegate)
7373 : timeout_(timeout),
7474timer_ (resolver.get_io_service()),
75+ is_timedout_(false ),
7576 follow_redirect_(follow_redirect),
7677 resolver_(resolver),
7778 resolve_(resolve),
@@ -122,6 +123,7 @@ struct http_async_connection
122123
123124void handle_timeout (boost::system::error_codeconst &ec) {
124125if (!ec) delegate_->disconnect ();
126+ is_timedout_ =true ;
125127 }
126128
127129void handle_resolved (boost::uint16_t port,bool get_body,
@@ -152,7 +154,9 @@ struct http_async_connection
152154 body_generator_function_type generator,
153155 resolver_iterator_pair endpoint_range,
154156 boost::system::error_codeconst & ec) {
155- if (!ec) {
157+ if (is_timedout_) {
158+ set_errors (asio::error::timed_out);
159+ }else if (!ec) {
156160BOOST_ASSERT (delegate_.get () !=0 );
157161 delegate_->write (
158162 command_streambuf,
@@ -191,7 +195,7 @@ struct http_async_connection
191195 body_generator_function_type generator,
192196 boost::system::error_codeconst & ec,
193197 std::size_t bytes_transferred) {
194- if (!ec) {
198+ if (!is_timedout_ && ! ec) {
195199if (generator) {
196200// Here we write some more data that the generator provides, before
197201// we wait for data from the server.
@@ -219,7 +223,7 @@ struct http_async_connection
219223 version, get_body, callback, placeholders::error,
220224 placeholders::bytes_transferred)));
221225 }else {
222- set_errors (ec);
226+ set_errors (is_timedout_ ? asio::error::timed_out : ec);
223227 }
224228 }
225229
@@ -235,7 +239,8 @@ struct http_async_connection
235239#else
236240false && short_read_error;
237241#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)) {
239244 logic::tribool parsed_ok;
240245size_t remainder;
241246switch (state) {
@@ -403,7 +408,7 @@ struct http_async_connection
403408BOOST_ASSERT (false &&" Bug, report this to the developers!" );
404409 }
405410 }else {
406- boost::system::system_errorerror (ec);
411+ boost::system::system_errorerror (is_timedout_ ? asio::error::timed_out : ec);
407412this ->source_promise .set_exception (boost::copy_exception (error));
408413this ->destination_promise .set_exception (boost::copy_exception (error));
409414switch (state) {
@@ -454,6 +459,7 @@ struct http_async_connection
454459
455460int timeout_;
456461 boost::asio::deadline_timer timer_;
462+ bool is_timedout_;
457463bool follow_redirect_;
458464 resolver_type& resolver_;
459465 resolve_function resolve_;