From 0468814ee0e2f085f1cc36ff3c235050946652ce Mon Sep 17 00:00:00 2001 From: "Billy O'Neal (VC LIBS)" Date: Mon, 18 Mar 2019 16:15:59 -0700 Subject: [PATCH 1/2] Only close the output stream in _complete when the HTTP message created the stream on the user's behalf. --- Release/src/http/common/http_msg.cpp | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/Release/src/http/common/http_msg.cpp b/Release/src/http/common/http_msg.cpp index 50ab8ed82c..50332fd1e9 100644 --- a/Release/src/http/common/http_msg.cpp +++ b/Release/src/http/common/http_msg.cpp @@ -427,14 +427,25 @@ void http_msg_base::_complete(utility::size64_t body_size, const std::exception_ { const auto& completionEvent = _get_data_available(); auto closeTask = pplx::task_from_result(); - - if (exceptionPtr == std::exception_ptr()) + if (m_default_outstream) { - if (m_default_outstream) + // if the outstream is one we created by default on the customer's behalf, try to close it + auto& out = outstream(); + if (out.is_valid()) { - closeTask = outstream().close(); + if (exceptionPtr == std::exception_ptr()) + { + closeTask = out.close(); + } + else + { + closeTask = out.close(exceptionPtr); + } } + } + if (exceptionPtr == std::exception_ptr()) + { inline_continuation(closeTask, [completionEvent, body_size](pplx::task t) { try { @@ -459,11 +470,6 @@ void http_msg_base::_complete(utility::size64_t body_size, const std::exception_ } else { - if (outstream().is_valid()) - { - closeTask = outstream().close(exceptionPtr); - } - inline_continuation(closeTask, [completionEvent, exceptionPtr](pplx::task t) { // If closing stream throws an exception ignore since we already have an error. try From 5323ce843df4dc6e030edb3784937ac083605e0f Mon Sep 17 00:00:00 2001 From: Billy Robert O'Neal III Date: Mon, 18 Mar 2019 16:26:45 -0700 Subject: [PATCH 2/2] Turn on repaired test. --- .../functional/http/client/connections_and_errors.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/Release/tests/functional/http/client/connections_and_errors.cpp b/Release/tests/functional/http/client/connections_and_errors.cpp index 22e0fc828f..9ddcc09fb7 100644 --- a/Release/tests/functional/http/client/connections_and_errors.cpp +++ b/Release/tests/functional/http/client/connections_and_errors.cpp @@ -226,12 +226,7 @@ SUITE(connections_and_errors) http_response rsp = client.request(msg).get(); // The response body should timeout and we should receive an exception -#ifndef _WIN32 - // CodePlex 295 - VERIFY_THROWS(rsp.content_ready().wait(), http_exception); -#else VERIFY_THROWS_HTTP_ERROR_CODE(rsp.content_ready().wait(), std::errc::timed_out); -#endif } buf.close(std::ios_base::out).wait(); @@ -261,12 +256,7 @@ SUITE(connections_and_errors) // The response body should timeout and we should receive an exception auto readTask = rsp.body().read_to_end(streams::producer_consumer_buffer()); -#ifndef _WIN32 - // CodePlex 295 - VERIFY_THROWS(readTask.get(), http_exception); -#else VERIFY_THROWS_HTTP_ERROR_CODE(readTask.wait(), std::errc::timed_out); -#endif } buf.close(std::ios_base::out).wait();