mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 01:25:21 +00:00
Better
This commit is contained in:
parent
cb904d4f3e
commit
fb8241c651
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user