From efbfbdc7a3f9e63b523fa43992092f623065a4b6 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Wed, 1 Feb 2017 04:19:32 +0300 Subject: [PATCH] Added setting 'send_progress_in_http_headers', disabled by default [#CLICKHOUSE-32]. --- dbms/include/DB/Interpreters/Settings.h | 5 +++++ dbms/src/Server/HTTPHandler.cpp | 15 +++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/dbms/include/DB/Interpreters/Settings.h b/dbms/include/DB/Interpreters/Settings.h index d1a6b619f2e..3a3668e7bd6 100644 --- a/dbms/include/DB/Interpreters/Settings.h +++ b/dbms/include/DB/Interpreters/Settings.h @@ -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) \ \ diff --git a/dbms/src/Server/HTTPHandler.cpp b/dbms/src/Server/HTTPHandler.cpp index 5767014ec8c..4edbe85b5d1 100644 --- a/dbms/src/Server/HTTPHandler.cpp +++ b/dbms/src/Server/HTTPHandler.cpp @@ -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(*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); });