@@ -118,7 +118,7 @@ struct http_async_connection
118118 }
119119
120120private:
121- void set_errors (std::error_codeconst & ec) {
121+ void set_errors (std::error_codeconst & ec, body_callback_function_type callback ) {
122122 std::system_errorerror (ec);
123123this ->version_promise .set_exception (std::make_exception_ptr (error));
124124this ->status_promise .set_exception (std::make_exception_ptr (error));
@@ -127,6 +127,8 @@ struct http_async_connection
127127this ->source_promise .set_exception (std::make_exception_ptr (error));
128128this ->destination_promise .set_exception (std::make_exception_ptr (error));
129129this ->body_promise .set_exception (std::make_exception_ptr (error));
130+ if ( callback )
131+ callback ( boost::iterator_range<const char *>(), ec );
130132this ->timer_ .cancel ();
131133 }
132134
@@ -155,9 +157,7 @@ struct http_async_connection
155157 generator,std::make_pair (++iter_copy,resolver_iterator ()), ec);
156158 }));
157159 }else {
158- set_errors (ec ? ec : ::asio::error::host_not_found);
159- boost::iterator_range<const char *> range;
160- if (callback)callback (range, ec);
160+ set_errors ((ec ? ec : ::asio::error::host_not_found), callback);
161161 }
162162 }
163163
@@ -168,7 +168,7 @@ struct http_async_connection
168168 resolver_iterator_pair endpoint_range,
169169 std::error_codeconst & ec) {
170170if (is_timedout_) {
171- set_errors (::asio::error::timed_out);
171+ set_errors (::asio::error::timed_out, callback );
172172 }else if (!ec) {
173173BOOST_ASSERT (delegate_.get () !=0 );
174174auto self =this ->shared_from_this ();
@@ -193,9 +193,7 @@ struct http_async_connection
193193 ec);
194194 }));
195195 }else {
196- set_errors (ec ? ec : ::asio::error::host_not_found);
197- boost::iterator_range<const char *> range;
198- if (callback)callback (range, ec);
196+ set_errors ((ec ? ec : ::asio::error::host_not_found), callback);
199197 }
200198 }
201199 }
@@ -239,7 +237,7 @@ struct http_async_connection
239237 ec, bytes_transferred);
240238 }));
241239 }else {
242- set_errors (is_timedout_ ? ::asio::error::timed_out : ec);
240+ set_errors (( is_timedout_ ? ::asio::error::timed_out : ec), callback );
243241 }
244242 }
245243
@@ -322,6 +320,8 @@ struct http_async_connection
322320// We short-circuit here because the user does not want to get the
323321// body (in the case of a HEAD request).
324322this ->body_promise .set_value (" " );
323+ if ( callback )
324+ callback ( boost::iterator_range<const char *>(), ::asio::error::eof );
325325this ->destination_promise .set_value (" " );
326326this ->source_promise .set_value (" " );
327327// this->part.assign('\0');
@@ -446,8 +446,8 @@ struct http_async_connection
446446BOOST_ASSERT (false &&" Bug, report this to the developers!" );
447447 }
448448 }else {
449- std::system_error error ( is_timedout_ ? ::asio::error::timed_out
450- : ec );
449+ std::error_code report_code = is_timedout_ ? ::asio::error::timed_out : ec;
450+ std::system_error error (report_code );
451451this ->source_promise .set_exception (std::make_exception_ptr (error));
452452this ->destination_promise .set_exception (std::make_exception_ptr (error));
453453switch (state) {
@@ -467,6 +467,8 @@ struct http_async_connection
467467// so no exception should be set
468468this ->body_promise .set_exception (std::make_exception_ptr (error));
469469 }
470+ else
471+ callback ( boost::iterator_range<const char *>(), report_code );
470472break ;
471473default :
472474BOOST_ASSERT (false &&" Bug, report this to the developers!" );