Read until end of file in response reading test-cases

This commit is contained in:
Johannes Schmidt 2026-04-02 13:32:43 +02:00
parent 2717084148
commit 339434c8b4
2 changed files with 12 additions and 3 deletions

View file

@ -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);

View file

@ -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};