summaryrefslogtreecommitdiffstats
path: root/src/lib/http/tests
diff options
context:
space:
mode:
authorMarcin Siodelski <marcin@isc.org>2017-04-25 14:04:10 +0200
committerMarcin Siodelski <marcin@isc.org>2017-04-25 14:04:10 +0200
commitd4cf144a763b2c86bc6eef683bfa61875beb89f8 (patch)
treeb269fd2856cec54ed375d6dbce59ffd3b7c6c5a9 /src/lib/http/tests
parent[5260] HttpConnection callbacks migrated to shared_ptr. (diff)
downloadkea-d4cf144a763b2c86bc6eef683bfa61875beb89f8.tar.xz
kea-d4cf144a763b2c86bc6eef683bfa61875beb89f8.zip
[5260] Properly handle EWOULDBLOCK and EAGAIN in Http unit tests.
Diffstat (limited to 'src/lib/http/tests')
-rw-r--r--src/lib/http/tests/listener_unittests.cc38
1 files changed, 28 insertions, 10 deletions
diff --git a/src/lib/http/tests/listener_unittests.cc b/src/lib/http/tests/listener_unittests.cc
index 2149a83595..4ccc0a51eb 100644
--- a/src/lib/http/tests/listener_unittests.cc
+++ b/src/lib/http/tests/listener_unittests.cc
@@ -168,10 +168,21 @@ public:
[this, request](const boost::system::error_code& ec,
std::size_t bytes_transferred) mutable {
if (ec) {
- ADD_FAILURE() << "error occurred while connecting: "
- << ec.message();
- io_service_.stop();
- return;
+ if (ec.value() == boost::asio::error::operation_aborted) {
+ return;
+
+ } else if ((ec.value() == boost::asio::error::try_again) ||
+ (ec.value() == boost::asio::error::would_block)) {
+ // If we should try again make sure there is no garbage in the
+ // bytes_transferred.
+ bytes_transferred = 0;
+
+ } else {
+ ADD_FAILURE() << "error occurred while connecting: "
+ << ec.message();
+ io_service_.stop();
+ return;
+ }
}
// Remove the part of the request which has been sent.
@@ -199,14 +210,21 @@ public:
std::size_t bytes_transferred) {
if (ec) {
// IO service stopped so simply return.
- if (ec == boost::asio::error::operation_aborted) {
+ if (ec.value() == boost::asio::error::operation_aborted) {
return;
- }
- // Error occurred, bail...
- ADD_FAILURE() << "error occurred while receiving HTTP"
- " response from the server: " << ec.message();
- io_service_.stop();
+ } else if ((ec.value() == boost::asio::error::try_again) ||
+ (ec.value() == boost::asio::error::would_block)) {
+ // If we should try again, make sure that there is no garbage
+ // in the bytes_transferred.
+ bytes_transferred = 0;
+
+ } else {
+ // Error occurred, bail...
+ ADD_FAILURE() << "error occurred while receiving HTTP"
+ " response from the server: " << ec.message();
+ io_service_.stop();
+ }
}
if (bytes_transferred > 0) {