mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Merge pull request #71486 from ClickHouse/backport/24.8/68975
Backport #68975 to 24.8: `Content-Encoding` was not sent on progress
This commit is contained in:
commit
488f78ce93
@ -83,7 +83,11 @@ void WriteBufferFromHTTPServerResponse::finishSendHeaders()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (!headers_started_sending)
|
if (!headers_started_sending)
|
||||||
|
{
|
||||||
|
if (compression_method != CompressionMethod::None)
|
||||||
|
response.set("Content-Encoding", toContentEncodingName(compression_method));
|
||||||
startSendHeaders();
|
startSendHeaders();
|
||||||
|
}
|
||||||
|
|
||||||
writeHeaderSummary();
|
writeHeaderSummary();
|
||||||
writeExceptionCode();
|
writeExceptionCode();
|
||||||
@ -105,7 +109,13 @@ void WriteBufferFromHTTPServerResponse::nextImpl()
|
|||||||
initialized = true;
|
initialized = true;
|
||||||
|
|
||||||
if (compression_method != CompressionMethod::None)
|
if (compression_method != CompressionMethod::None)
|
||||||
response.set("Content-Encoding", toContentEncodingName(compression_method));
|
{
|
||||||
|
/// If we've already sent headers, just send the `Content-Encoding` down the socket directly
|
||||||
|
if (headers_started_sending)
|
||||||
|
socketSendStr("Content-Encoding: " + toContentEncodingName(compression_method) + "\r\n");
|
||||||
|
else
|
||||||
|
response.set("Content-Encoding", toContentEncodingName(compression_method));
|
||||||
|
}
|
||||||
|
|
||||||
startSendHeaders();
|
startSendHeaders();
|
||||||
finishSendHeaders();
|
finishSendHeaders();
|
||||||
@ -177,8 +187,12 @@ void WriteBufferFromHTTPServerResponse::finalizeImpl()
|
|||||||
/// If no body data just send header
|
/// If no body data just send header
|
||||||
startSendHeaders();
|
startSendHeaders();
|
||||||
|
|
||||||
|
/// `finalizeImpl` must be idempotent, so set `initialized` here to not send stuff twice
|
||||||
if (!initialized && offset() && compression_method != CompressionMethod::None)
|
if (!initialized && offset() && compression_method != CompressionMethod::None)
|
||||||
|
{
|
||||||
|
initialized = true;
|
||||||
socketSendStr("Content-Encoding: " + toContentEncodingName(compression_method) + "\r\n");
|
socketSendStr("Content-Encoding: " + toContentEncodingName(compression_method) + "\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
finishSendHeaders();
|
finishSendHeaders();
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
< Content-Encoding: zstd
|
||||||
|
< Content-Encoding: zstd
|
16
tests/queries/0_stateless/03172_http_content_encoding.sh
Executable file
16
tests/queries/0_stateless/03172_http_content_encoding.sh
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||||
|
# shellcheck source=../shell_config.sh
|
||||||
|
. "$CURDIR"/../shell_config.sh
|
||||||
|
|
||||||
|
URL="${CLICKHOUSE_PORT_HTTP_PROTO}://${CLICKHOUSE_HOST}:${CLICKHOUSE_PORT_HTTP}/"
|
||||||
|
|
||||||
|
# with progress
|
||||||
|
${CLICKHOUSE_CURL} -vsS "${URL}?send_progress_in_http_headers=1&enable_http_compression=1&wait_end_of_query=0" -o /dev/null \
|
||||||
|
-H 'Accept-Encoding: zstd' --compressed --data-binary @- <<< "select distinct sleep(.1),name from generateRandom('name String',1,1000,2) limit 100009 format TSV" 2>&1 \
|
||||||
|
| perl -lnE 'print if /Content-Encoding/';
|
||||||
|
# no progress
|
||||||
|
${CLICKHOUSE_CURL} -vsS "${URL}?send_progress_in_http_headers=0&enable_http_compression=1&wait_end_of_query=0" -o /dev/null \
|
||||||
|
-H 'Accept-Encoding: zstd' --compressed --data-binary @- <<< "select distinct sleep(.1),name from generateRandom('name String',1,1000,2) limit 100009 format TSV" 2>&1 \
|
||||||
|
| perl -lnE 'print if /Content-Encoding/';
|
Loading…
Reference in New Issue
Block a user