提交 7a75003d 编写于 作者: G Guillaume Tassery

Send X-ClickHouse-Progress header in the end of a query execution

上级 cdc65eca
......@@ -36,11 +36,24 @@ void WriteBufferFromHTTPServerResponse::startSendHeaders()
}
}
void WriteBufferFromHTTPServerResponse::writeHeaderProgress()
{
if (headers_finished_sending)
return;
WriteBufferFromOwnString progress_string_writer;
accumulated_progress.writeJSON(progress_string_writer);
#if defined(POCO_CLICKHOUSE_PATCH)
*response_header_ostr << "X-ClickHouse-Progress: " << progress_string_writer.str() << "\r\n" << std::flush;
#endif
}
void WriteBufferFromHTTPServerResponse::finishSendHeaders()
{
if (!headers_finished_sending)
{
writeHeaderProgress();
headers_finished_sending = true;
if (request.getMethod() != Poco::Net::HTTPRequest::HTTP_HEAD)
......@@ -174,13 +187,7 @@ void WriteBufferFromHTTPServerResponse::onProgress(const Progress & progress)
/// Send all common headers before our special progress headers.
startSendHeaders();
WriteBufferFromOwnString progress_string_writer;
accumulated_progress.writeJSON(progress_string_writer);
#if defined(POCO_CLICKHOUSE_PATCH)
*response_header_ostr << "X-ClickHouse-Progress: " << progress_string_writer.str() << "\r\n" << std::flush;
#endif
writeHeaderProgress();
}
}
......
......@@ -80,6 +80,9 @@ private:
/// but not finish them with \r\n, allowing to send more headers subsequently.
void startSendHeaders();
// Used for write the header X-ClickHouse-progress
void writeHeaderProgress();
/// This method finish headers with \r\n, allowing to start to send body.
void finishSendHeaders();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册