mirror of
https://github.com/Icinga/icinga2.git
synced 2026-05-28 04:12:13 -04:00
Read until end of file in response reading test-cases
This commit is contained in:
parent
2717084148
commit
339434c8b4
2 changed files with 12 additions and 3 deletions
|
|
@ -71,11 +71,20 @@ public:
|
|||
BOOST_REQUIRE(stream->next_layer().IsVerifyOK());
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
void Shutdown(bool wait = false)
|
||||
{
|
||||
BOOST_REQUIRE(std::holds_alternative<Shared<AsioTlsStream>::Ptr>(m_Stream));
|
||||
auto& stream = std::get<Shared<AsioTlsStream>::Ptr>(m_Stream);
|
||||
try {
|
||||
if (wait) {
|
||||
std::array<std::byte, 128> buf{};
|
||||
boost::asio::mutable_buffer readBuf (buf.data(), buf.size());
|
||||
boost::system::error_code ec;
|
||||
|
||||
do {
|
||||
stream->read_some(readBuf, ec);
|
||||
} while (!ec);
|
||||
}
|
||||
stream->next_layer().shutdown();
|
||||
} catch (const std::exception& ex) {
|
||||
if (const auto* se = dynamic_cast<const boost::system::system_error*>(&ex);
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ BOOST_AUTO_TEST_CASE(stuck_reading_response)
|
|||
requestReadPromise.set_value();
|
||||
// Do not send a response but react to the shutdown to be polite.
|
||||
shutdownPromise.get_future().get();
|
||||
Shutdown();
|
||||
Shutdown(true);
|
||||
}};
|
||||
|
||||
TestThread timeoutThread{[&]() {
|
||||
|
|
@ -315,7 +315,7 @@ BOOST_AUTO_TEST_CASE(http_send_retry)
|
|||
|
||||
SendResponse();
|
||||
|
||||
Shutdown();
|
||||
Shutdown(true);
|
||||
}};
|
||||
|
||||
boost::beast::http::request<boost::beast::http::string_body> request{boost::beast::http::verb::post, "foo", 10};
|
||||
|
|
|
|||
Loading…
Reference in a new issue