Added setting 'send_progress_in_http_headers', disabled by default [#CLICKHOUSE-32].

This commit is contained in:
Alexey Milovidov 2017-02-01 04:19:32 +03:00
parent cb11b2e46f
commit efbfbdc7a3
2 changed files with 14 additions and 6 deletions

View File

@ -239,6 +239,11 @@ struct Settings
/** Use client timezone for interpreting DateTime string values, instead of adopting server timezone. */ \
M(SettingBool, use_client_time_zone, false) \
\
/** Send progress notifications using X-ClickHouse-Progress headers. \
* Some clients do not support high amount of HTTP headers (Python requests in particular), so it is disabled by default. \
*/ \
M(SettingBool, send_progress_in_http_headers, false) \
\
/** Do not send HTTP headers X-ClickHouse-Progress more frequently than at each specified interval. */ \
M(SettingUInt64, http_headers_progress_interval_ms, 100) \
\

View File

@ -226,22 +226,24 @@ void HTTPHandler::processQuery(
}
}
const Settings & settings = context.getSettingsRef();
/// HTTP response compression is turned on only if the client signalled that they support it
/// (using Accept-Encoding header) and 'enable_http_compression' setting is turned on.
used_output.out->setCompression(client_supports_http_compression && context.getSettingsRef().enable_http_compression);
used_output.out->setCompression(client_supports_http_compression && settings.enable_http_compression);
if (client_supports_http_compression)
used_output.out->setCompressionLevel(context.getSettingsRef().http_zlib_compression_level);
used_output.out->setCompressionLevel(settings.http_zlib_compression_level);
used_output.out->setSendProgressInterval(context.getSettingsRef().http_headers_progress_interval_ms);
used_output.out->setSendProgressInterval(settings.http_headers_progress_interval_ms);
/// If 'http_native_compression_disable_checksumming_on_decompress' setting is turned on,
/// checksums of client data compressed with internal algorithm are not checked.
if (in_post_compressed && context.getSettingsRef().http_native_compression_disable_checksumming_on_decompress)
if (in_post_compressed && settings.http_native_compression_disable_checksumming_on_decompress)
static_cast<CompressedReadBuffer &>(*in_post_maybe_compressed).disableChecksumming();
/// Add CORS header if 'add_http_cors_header' setting is turned on and the client passed
/// Origin header.
used_output.out->addHeaderCORS( context.getSettingsRef().add_http_cors_header && !request.get("Origin", "").empty() );
used_output.out->addHeaderCORS(settings.add_http_cors_header && !request.get("Origin", "").empty());
ClientInfo & client_info = context.getClientInfo();
client_info.query_kind = ClientInfo::QueryKind::INITIAL_QUERY;
@ -262,7 +264,8 @@ void HTTPHandler::processQuery(
client_info.http_user_agent = request.get("User-Agent", "");
/// While still no data has been sent, we will report about query execution progress by sending HTTP headers.
context.setProgressCallback([&used_output] (const Progress & progress) { used_output.out->onProgress(progress); });
if (settings.send_progress_in_http_headers)
context.setProgressCallback([&used_output] (const Progress & progress) { used_output.out->onProgress(progress); });
executeQuery(*in, *used_output.out_maybe_compressed, /* allow_into_outfile = */ false, context,
[&response] (const String & content_type) { response.setContentType(content_type); });