Skip to content

Commit 124609d

Browse files
author
Thomas Schaub
committed
Fix http_client_asio cancel bug
1 parent 2321e84 commit 124609d

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

Release/src/http/client/http_client_asio.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,10 @@ class asio_context : public request_context, public std::enable_shared_from_this
792792
{
793793
write_request();
794794
}
795+
else if (ec.value() == boost::system::errc::operation_canceled)
796+
{
797+
request_context::report_error(ec.value(), "Request canceled by user.");
798+
}
795799
else if (endpoints == tcp::resolver::iterator())
796800
{
797801
report_error("Failed to connect to any resolved endpoint", ec, httpclient_errorcode_context::connect);

Release/tests/functional/http/client/connections_and_errors.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -406,13 +406,13 @@ TEST_FIXTURE(uri_address, cancel_while_downloading_data)
406406
// Try to connect to a server on a closed port and cancel the operation.
407407
TEST_FIXTURE(uri_address, cancel_bad_port)
408408
{
409-
// http_client_asio has a bug where, when canceled, it will cancel only the
409+
// http_client_asio had a bug where, when canceled, it would cancel only the
410410
// current connection but then go and try the next address from the list of
411-
// resolved addresses, i.e., it won't actually cancel as long as there are
412-
// more addresses to try. Consequently, it will not report the task as being
413-
// canceled. This is easiest to observe when trying to connect to a server
414-
// that does not respond on a certain port, otherwise the timing might be
415-
// tricky.
411+
// resolved addresses, i.e., it wouldn't actually cancel as long as there
412+
// are more addresses to try. Consequently, it would not report the task as
413+
// being canceled. This was easiest to observe when trying to connect to a
414+
// server that does not respond on a certain port, otherwise the timing
415+
// might be tricky.
416416

417417
// We need to connect to a URI for which there are multiple addresses
418418
// associated (i.e., multiple A records).

0 commit comments

Comments
 (0)