Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix for: Body callback function is not called when some errors occur …#642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix for: Body callback function is not called when some errors occur …
…(timeout etc.)#640
  • Loading branch information
Grzegorz Baran committedApr 21, 2016
commit66fa71c01e8ca075409588ef5fe178a210538898
24 changes: 13 additions & 11 deletionsboost/network/protocol/http/client/connection/async_normal.hpp
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -118,7 +118,7 @@ struct http_async_connection
}

private:
voidset_errors(std::error_codeconst& ec) {
voidset_errors(std::error_codeconst& ec, body_callback_function_type callback) {
std::system_errorerror(ec);
this->version_promise.set_exception(std::make_exception_ptr(error));
this->status_promise.set_exception(std::make_exception_ptr(error));
Expand All@@ -127,6 +127,8 @@ struct http_async_connection
this->source_promise.set_exception(std::make_exception_ptr(error));
this->destination_promise.set_exception(std::make_exception_ptr(error));
this->body_promise.set_exception(std::make_exception_ptr(error));
if ( callback )
callback( boost::iterator_range<constchar*>(), ec );
this->timer_.cancel();
}

Expand DownExpand Up@@ -155,9 +157,7 @@ struct http_async_connection
generator,std::make_pair(++iter_copy,resolver_iterator()), ec);
}));
}else {
set_errors(ec ? ec : ::asio::error::host_not_found);
boost::iterator_range<constchar*> range;
if (callback)callback(range, ec);
set_errors((ec ? ec : ::asio::error::host_not_found), callback);
}
}

Expand All@@ -168,7 +168,7 @@ struct http_async_connection
resolver_iterator_pair endpoint_range,
std::error_codeconst& ec) {
if (is_timedout_) {
set_errors(::asio::error::timed_out);
set_errors(::asio::error::timed_out, callback);
}elseif (!ec) {
BOOST_ASSERT(delegate_.get() !=0);
auto self =this->shared_from_this();
Expand All@@ -193,9 +193,7 @@ struct http_async_connection
ec);
}));
}else {
set_errors(ec ? ec : ::asio::error::host_not_found);
boost::iterator_range<constchar*> range;
if (callback)callback(range, ec);
set_errors((ec ? ec : ::asio::error::host_not_found), callback);
}
}
}
Expand DownExpand Up@@ -239,7 +237,7 @@ struct http_async_connection
ec, bytes_transferred);
}));
}else {
set_errors(is_timedout_ ? ::asio::error::timed_out : ec);
set_errors((is_timedout_ ? ::asio::error::timed_out : ec), callback);
}
}

Expand DownExpand Up@@ -322,6 +320,8 @@ struct http_async_connection
// We short-circuit here because the user does not want to get the
// body (in the case of a HEAD request).
this->body_promise.set_value("");
if ( callback )
callback( boost::iterator_range<constchar*>(), ::asio::error::eof );
this->destination_promise.set_value("");
this->source_promise.set_value("");
// this->part.assign('\0');
Expand DownExpand Up@@ -446,8 +446,8 @@ struct http_async_connection
BOOST_ASSERT(false &&"Bug, report this to the developers!");
}
}else {
std::system_errorerror(is_timedout_ ? ::asio::error::timed_out
: ec);
std::error_code report_code =is_timedout_ ? ::asio::error::timed_out : ec;
std::system_errorerror(report_code);
this->source_promise.set_exception(std::make_exception_ptr(error));
this->destination_promise.set_exception(std::make_exception_ptr(error));
switch (state) {
Expand All@@ -467,6 +467,8 @@ struct http_async_connection
// so no exception should be set
this->body_promise.set_exception(std::make_exception_ptr(error));
}
else
callback( boost::iterator_range<constchar*>(), report_code );
break;
default:
BOOST_ASSERT(false &&"Bug, report this to the developers!");
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp