This commit is contained in:
Antonio Andelic 2024-03-04 16:36:46 +01:00
parent cb904d4f3e
commit fb8241c651

View File

@ -91,24 +91,35 @@ void InterserverIOHTTPHandler::handleRequest(HTTPServerRequest & request, HTTPSe
used_output.out = std::make_shared<WriteBufferFromHTTPServerResponse>(
response, request.getMethod() == Poco::Net::HTTPRequest::HTTP_HEAD, keep_alive_timeout, write_event);
auto finalize_output = [&]
{
try
{
used_output.out->finalize();
}
catch (...)
{
tryLogCurrentException(log, "Failed to finalize response write buffer");
}
};
auto write_response = [&](const std::string & message)
{
auto & out = *used_output.out;
if (response.sent())
{
out.finalize();
finalize_output();
return;
}
try
{
writeString(message, out);
out.finalize();
writeString(message, *used_output.out);
finalize_output();
}
catch (...)
{
tryLogCurrentException(log);
out.finalize();
finalize_output();
}
};
@ -117,17 +128,7 @@ void InterserverIOHTTPHandler::handleRequest(HTTPServerRequest & request, HTTPSe
if (auto [message, success] = checkAuthentication(request); success)
{
processQuery(request, response, used_output);
try
{
used_output.out->finalize();
}
catch (...)
{
tryLogCurrentException(log, "Failed to finalize response write buffer");
return;
}
finalize_output();
LOG_DEBUG(log, "Done processing query");
}
else