-
Notifications
You must be signed in to change notification settings - Fork 9k
Expand file tree
/
Copy pathHTTPHandler.cpp
More file actions
2078 lines (1852 loc) · 107 KB
/
Copy pathHTTPHandler.cpp
File metadata and controls
2078 lines (1852 loc) · 107 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <Server/HTTPHandler.h>
#include <Server/HTTPQueryConstructor.h>
#include <Access/AccessControl.h>
#include <Compression/CompressedReadBuffer.h>
#include <Compression/CompressedWriteBuffer.h>
#include <Compression/chooseNetworkCompressionCodec.h>
#include <Core/ExternalTable.h>
#include <Core/ServerSettings.h>
#include <Core/Settings.h>
#include <IO/CompressionMethod.h>
#include <IO/WriteBufferFromString.h>
#include <Poco/URI.h>
#include <Common/quoteString.h>
#include <Disks/StoragePolicy.h>
#include <IO/CascadeWriteBuffer.h>
#include <IO/ConcatReadBuffer.h>
#include <IO/MemoryReadWriteBuffer.h>
#include <IO/ReadBuffer.h>
#include <IO/ReadBufferFromString.h>
#include <IO/WriteHelpers.h>
#include <IO/copyData.h>
#include <Interpreters/Context.h>
#include <Interpreters/DatabaseCatalog.h>
#include <Interpreters/TableNameHints.h>
#include <Interpreters/TemporaryDataOnDisk.h>
#include <Parsers/Lexer.h>
#include <Parsers/QueryParameterVisitor.h>
#include <Common/SQLDefinedHandlers/SQLDefinedHandler.h>
#include <Interpreters/executeQuery.h>
#include <Interpreters/Session.h>
#include <Processors/Port.h>
#include <Server/HTTPHandlerFactory.h>
#include <Server/HTTPHandlerRequestFilter.h>
#include <Server/IServer.h>
#include <Common/CurrentThread.h>
#include <Common/FailPoint.h>
#include <Common/Logger.h>
#include <Common/logger_useful.h>
#include <Common/maskSensitiveQueryParameters.h>
#include <Common/SettingsChanges.h>
#include <Common/StringUtils.h>
#include <Common/scope_guard_safe.h>
#include <Common/setThreadName.h>
#include <Common/typeid_cast.h>
#include <Parsers/ASTSetQuery.h>
#include <Processors/Formats/Framing/FramingFormatFactory.h>
#include <Processors/Formats/IOutputFormat.h>
#include <Formats/FormatFactory.h>
#include <base/getFQDNOrHostName.h>
#include <base/isSharedPtrUnique.h>
#include <Server/HTTP/HTTPResponse.h>
#include <Server/HTTP/authenticateUserByHTTP.h>
#include <Server/HTTP/deferHTTP100Continue.h>
#include <Server/HTTP/sendExceptionToHTTPClient.h>
#include <Server/HTTP/setReadOnlyIfHTTPMethodIdempotent.h>
#include <Poco/Net/HTTPMessage.h>
#include <Poco/Util/LayeredConfiguration.h>
#include <algorithm>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <memory>
#include <optional>
#include <string_view>
#include <unordered_map>
#include <utility>
namespace DB
{
namespace Setting
{
extern const SettingsBool add_http_cors_header;
extern const SettingsBool cancel_http_readonly_queries_on_client_close;
extern const SettingsBool enable_http_compression;
extern const SettingsUInt64 http_headers_progress_interval_ms;
extern const SettingsUInt64 http_max_request_param_data_size;
extern const SettingsBool http_native_compression_disable_checksumming_on_decompress;
extern const SettingsUInt64 http_response_buffer_size;
extern const SettingsBool http_wait_end_of_query;
extern const SettingsBool http_write_exception_in_output_format;
extern const SettingsInt64 http_zlib_compression_level;
extern const SettingsUInt64 input_format_max_block_wait_ms;
extern const SettingsUInt64 readonly;
extern const SettingsBool run_query_in_background;
extern const SettingsBool send_progress_in_http_headers;
extern const SettingsSnappyMode snappy_mode;
extern const SettingsBool throw_on_unsupported_query_inside_transaction;
extern const SettingsInt64 zstd_window_log_max;
extern const SettingsBool http_allow_database_as_path;
extern const SettingsBool http_allow_table_as_file;
extern const SettingsBool http_allow_filters_as_path;
extern const SettingsBool http_allow_filters_as_unrecognized_url_parameters;
extern const SettingsString compression;
extern const SettingsString filter;
extern const SettingsString format;
extern const SettingsString input_format;
extern const SettingsString output_format;
extern const SettingsString default_format;
extern const SettingsString database;
extern const SettingsString implicit_table_at_top_level;
}
namespace ErrorCodes
{
extern const int LOGICAL_ERROR;
extern const int NO_ELEMENTS_IN_CONFIG;
extern const int INVALID_SESSION_TIMEOUT;
extern const int INVALID_CONFIG_PARAMETER;
extern const int HTTP_LENGTH_REQUIRED;
extern const int SESSION_ID_EMPTY;
extern const int BAD_ARGUMENTS;
extern const int UNKNOWN_TABLE;
extern const int NOT_IMPLEMENTED;
extern const int FAULT_INJECTED;
}
namespace FailPoints
{
extern const char http_output_finalize_throw[];
extern const char http_push_delayed_results_throw[];
}
namespace
{
/// Whether the request declares a body that the HTTP handler layer reads by itself, regardless of the query:
/// Poco's `HTMLForm` loads `application/x-www-form-urlencoded` payloads, and `multipart/form-data` is parsed as
/// "external data for query processing". Such a body must come with a length on a non-chunked request.
bool requestDeclaresFormBody(const HTTPServerRequest & request)
{
const auto & content_type = request.getContentType();
return startsWith(content_type, "application/x-www-form-urlencoded")
|| startsWith(content_type, "multipart/form-data");
}
void addHTTPOptionHeadersFromConfig(HTTPServerResponse & response, const Poco::Util::LayeredConfiguration & config)
{
if (!config.has("http_options_response"))
return;
Strings config_keys;
config.keys("http_options_response", config_keys);
for (const std::string & config_key : config_keys)
{
if (config_key == "header" || config_key.starts_with("header["))
{
/// If there is empty header name, it will not be processed and message about it will be in logs
if (config.getString("http_options_response." + config_key + ".name", "").empty())
LOG_WARNING(getLogger("processOptionsRequest"), "Empty header was found in config. It will not be processed.");
else
response.add(config.getString("http_options_response." + config_key + ".name", ""),
config.getString("http_options_response." + config_key + ".value", ""));
}
}
}
/// Process options request. Useful for CORS.
void processOptionsRequest(HTTPServerResponse & response, const Poco::Util::LayeredConfiguration & config)
{
/// Add extra response headers (e.g. for CORS) when an `http_options_response` section is configured.
addHTTPOptionHeadersFromConfig(response, config);
/// Always answer an OPTIONS request, even when there is nothing to add from the config. Otherwise the
/// connection is closed without any HTTP response and the client sees an empty reply. The default
/// `clickhouse-server` config ships an `http_options_response` section, but `clickhouse-local` (which
/// typically runs without a config) does not, so without this the web UI (`/play`) reports the
/// connection as broken — its `OPTIONS` health-check fails — even though queries work.
response.setKeepAlive(false);
response.setStatusAndReason(HTTPResponse::HTTP_NO_CONTENT);
response.send();
}
}
static std::chrono::steady_clock::duration parseSessionTimeout(
const Poco::Util::AbstractConfiguration & config,
const HTMLForm & params)
{
unsigned session_timeout = config.getInt("default_session_timeout", 60);
if (params.has("session_timeout"))
{
unsigned max_session_timeout = config.getUInt("max_session_timeout", 3600);
std::string session_timeout_str = params.get("session_timeout");
ReadBufferFromString buf(session_timeout_str);
if (!tryReadIntText(session_timeout, buf) || !buf.eof())
throw Exception(ErrorCodes::INVALID_SESSION_TIMEOUT, "Invalid session timeout: '{}'", session_timeout_str);
if (session_timeout > max_session_timeout)
throw Exception(ErrorCodes::INVALID_SESSION_TIMEOUT, "Session timeout '{}' is larger than max_session_timeout: {}. "
"Maximum session timeout could be modified in configuration file.",
session_timeout_str, max_session_timeout);
}
return std::chrono::seconds(session_timeout);
}
/// Returns true if `url` starts with `prefix` and either matches it exactly or is followed by a
/// segment boundary (`/`, `?`, or `#`). Plain `starts_with` would also accept `/api/v11/...` under
/// prefix `/api/v1`, which leaks unrelated endpoints into the dynamic-query factory and produces
/// nonsensical path parsing after the prefix is stripped.
static bool hasUrlPrefixWithSegmentBoundary(std::string_view url, std::string_view prefix)
{
if (!url.starts_with(prefix))
return false;
if (url.size() == prefix.size())
return true;
/// A prefix that already ends in a boundary character (e.g. `/api/v1/`) is itself
/// segment-aligned, so any non-empty continuation is a valid child path: `/api/v1/db/hits`
/// must match prefix `/api/v1/` even though `url[prefix.size()]` is `d`.
if (!prefix.empty() && (prefix.back() == '/' || prefix.back() == '?' || prefix.back() == '#'))
return true;
const char next = url[prefix.size()];
return next == '/' || next == '?' || next == '#';
}
HTTPHandlerConnectionConfig::HTTPHandlerConnectionConfig(const Poco::Util::AbstractConfiguration & config, const std::string & config_prefix)
{
if (config.has(config_prefix + ".handler.password"))
throw Exception(ErrorCodes::INVALID_CONFIG_PARAMETER, "{}.handler.password will be ignored. Please remove it from config.", config_prefix);
if (config.has(config_prefix + ".handler.user"))
credentials.emplace(config.getString(config_prefix + ".handler.user", "default"));
}
HTTPHandler::HTTPHandler(IServer & server_, const HTTPHandlerConnectionConfig & connection_config_, const std::string & name, const HTTPResponseHeaderSetup & http_response_headers_override_, const std::string & url_prefix_, HTTPPathHintsPtr path_hints_)
: log(getLogger(name))
, server(server_)
, default_settings(server.context()->getSettingsRef())
, http_response_headers_override(http_response_headers_override_)
, url_prefix(url_prefix_)
, path_hints(std::move(path_hints_))
, connection_config(connection_config_)
{
server_display_name = server.config().getString("display_name", getFQDNOrHostName());
}
/// We need d-tor to be present in this translation unit to make it play well with some
/// forward decls in the header. Other than that, the default d-tor would be OK.
HTTPHandler::~HTTPHandler() = default;
bool HTTPHandler::authenticateUser(HTTPServerRequest & request, HTMLForm & params, HTTPServerResponse & response)
{
return authenticateUserByHTTP(request, params, response, *session, request_credentials, connection_config, server.context(), log);
}
void HTTPHandler::processQuery(
HTTPServerRequest & request,
HTMLForm & params,
HTTPServerResponse & response,
Output & used_output,
QueryScope & query_scope,
const ProfileEvents::Event & write_event)
{
using namespace Poco::Net;
LOG_TRACE(log, "Request URI: {}", maskSensitiveQueryParametersInURI(request.getURI()));
if (!authenticateUser(request, params, response))
return; // '401 Unauthorized' response with 'Negotiate' has been sent at this point.
/// The user could specify session identifier and session timeout.
/// It allows to modify settings, create temporary tables and reuse them in subsequent requests.
String session_id;
std::chrono::steady_clock::duration session_timeout;
bool session_is_set = params.has("session_id");
const auto & config = server.config();
/// Close http session (if any) after processing the request
bool close_session = false;
if (params.getParsed<bool>("close_session", false) && server.config().getBool("enable_http_close_session", true))
close_session = true;
if (session_is_set)
{
session_id = params.get("session_id");
if (session_id.empty())
throw Exception(ErrorCodes::SESSION_ID_EMPTY, "Session id query parameter was provided, but it was empty");
session_timeout = parseSessionTimeout(config, params);
std::string session_check = params.get("session_check", "");
session->makeSessionContext(session_id, session_timeout, session_check == "1");
}
else
{
session_id = "";
/// We should create it even if we don't have a session_id
session->makeSessionContext();
}
/// We need to have both releasing/closing a session here and below. The problem with having it only as a SCOPE_EXIT
/// is that it will be invoked after finalizing the buffer in the end of processQuery, and that technically means that
/// the client has received all the data, but the session is not released yet. And it can (and sometimes does) happen
/// that we'll try to acquire the same session in another request before releasing the session here, and the session for
/// the following request will be technically locked, while it shouldn't be.
/// Also, SCOPE_EXIT is still needed to release a session in case of any exception. If the exception occurs at some point
/// after releasing the session below, this whole call will be no-op (due to named_session being nullptr already inside a session).
SCOPE_EXIT_SAFE({ releaseOrCloseSession(session_id, close_session); });
bool has_external_data = startsWith(request.getContentType(), "multipart/form-data");
const AccessControl & access_control = session->sessionContext()->getAccessControl();
NameToNameMap query_parameters = session->sessionContext()->getQueryParameters();
auto param_could_be_skipped = [&] (const String & name)
{
/// Empty parameter appears when URL like ?&a=b or a=b&&c=d. Just skip them for user's convenience.
if (name.empty())
return true;
/// HTTP-specific parameters that are consumed by the handler itself and never propagated as settings.
/// `database` and `default_format` are NOT here — they are now proper settings and flow through the
/// settings pipeline (with `changeable_in_readonly` constraints in the default profile so they remain
/// settable on read-only HTTP methods).
/// `filter` is NOT here either: it is collected as a construction filter only after
/// `customizeQueryParam` has had a chance to bind it (e.g. a `predefined_query_handler` with a
/// `{filter:String}` query parameter); see the parameter loop below.
static const NameSet reserved_param_names{"compress", "decompress", "user", "password", "quota_key", "query_id", "stacktrace", "role",
"buffer_size", "wait_end_of_query", "session_id", "session_timeout", "session_check", "client_protocol_version", "close_session"};
if (reserved_param_names.contains(name))
return true;
if (has_external_data)
{
/// For external data we have unspecified parameters which literally are {'<temp_table_name>_format', '<temp_table_name>_types', '<temp_table_name>_structure'}.
/// That parameters are not supposed to be used in the query as a settings. They have to be skipped.
/// But we could not just skip all parameters with suffixes '_format', '_types', '_structure',
/// because some of them are used in the query as a settings, like 'date_time_input_format',
static const Names reserved_param_suffixes = {"_format", "_types", "_structure"};
for (const String & suffix : reserved_param_suffixes)
{
if (endsWith(name, suffix))
return (!access_control.isSettingNameAllowed(name));
}
}
return false;
};
auto is_known_setting = [&](const String & name) -> bool
{
/// A few names aren't declared as settings via `DECLARE(...)` but are still handled by
/// `Context::setSetting` as "settings" — most importantly `profile`, which triggers
/// profile loading rather than mapping to a stored value. Without this carve-out, those
/// names would be deferred to the unrecognized-URL-params path and (if the
/// `http_allow_filters_as_unrecognized_url_parameters` feature is on) misinterpreted as
/// filter expressions.
if (name == "profile")
return true;
return access_control.isSettingNameAllowed(name);
};
/// Collect filter URL parameters and unrecognized parameters (as filters when enabled).
/// We need to consult the resolved settings to decide what to do with unrecognized params,
/// so we apply settings in two phases: first the recognized ones, then optionally add filters
/// from unrecognized ones.
std::vector<String> url_filters_from_params;
std::vector<std::pair<String, String>> deferred_unrecognized_params;
/// Settings can be overridden in the query.
SettingsChanges settings_changes;
for (const auto & [key, value] : params)
{
if (param_could_be_skipped(key))
continue;
if (customizeQueryParam(query_parameters, key, value))
continue;
/// `filter` is a construction setting, but the HTTP interface allows multiple `?filter=`
/// parameters combined with AND, so collect them here rather than letting the single-valued
/// `is_known_setting` path apply only the last one. This runs after `customizeQueryParam`, so
/// a configured handler that binds a `filter` query parameter (e.g. a `predefined_query_handler`
/// with `{filter:String}`) still receives it.
if (key == "filter")
{
url_filters_from_params.push_back("(" + value + ")");
continue;
}
/// Recognized as a setting if it has a known setting name or starts with allowed prefixes.
/// Otherwise, defer for possible filter treatment.
if (is_known_setting(key))
settings_changes.setSetting(key, value);
else
deferred_unrecognized_params.emplace_back(key, value);
}
/// The `X-ClickHouse-Database` header is an alias for the `database` setting, and
/// `X-ClickHouse-Format` is an alias for the `output_format` setting. They override any matching
/// URL parameter (preserving the historical precedence).
///
/// `X-ClickHouse-Format` maps to `output_format` rather than to `default_format`: sending this
/// header means the client definitely wants the response in that format, so it is an explicit
/// override (winning over the query's `FORMAT` clause and the path extension), not a fallback
/// used only when nothing else selects a format. It maps to `output_format` and not to the
/// bidirectional `format`, because the header has always described the response only: the same
/// header on `INSERT INTO t FORMAT JSONEachRow …` must not reinterpret the request body.
if (auto header_value = request.get("X-ClickHouse-Database", ""); !header_value.empty())
settings_changes.setSetting("database", header_value);
if (auto header_value = request.get("X-ClickHouse-Format", ""); !header_value.empty())
settings_changes.setSetting("output_format", header_value);
ContextMutablePtr context;
{
/// To decide whether to make a detached query context, we need the run_query_in_background setting's value.
/// But the setting value may be altered by setting the profile via HTTP params.
/// So, we construct settings_changes (including profile) and then we apply them to a temporary context,
/// which was copied from the session context.
/// And from that we derive the effective value of run_query_in_background.
/// For HTTP handler, run_query_in_background cannot be enabled in the SETTINGS clause of the query.
auto tmp_context = Context::createCopy(session->sessionContext());
SettingsChanges settings_changes_copy = settings_changes;
tmp_context->checkSettingsConstraints(settings_changes_copy, SettingSource::QUERY);
tmp_context->applySettingsChanges(settings_changes_copy);
const bool run_query_in_background = tmp_context->getSettingsRef()[Setting::run_query_in_background];
const bool throw_on_unsupported_query_inside_transaction = tmp_context->getSettingsRef()[Setting::throw_on_unsupported_query_inside_transaction];
context = run_query_in_background ? session->makeDetachedQueryContext() : session->makeQueryContext();
if (run_query_in_background && session->sessionContext()->getCurrentTransaction()
&& throw_on_unsupported_query_inside_transaction)
throw Exception(ErrorCodes::NOT_IMPLEMENTED, "Background queries inside transactions are not supported");
}
context->setQueryParameters(query_parameters);
/// Expose the HTTP request URL and the SQL-defined handler name (if any) to the query
/// via `currentRequestURL()` / `currentHandler()` and the query_log.
context->setHTTPRequestURL(request.getURI());
if (!introspection_handler_name.empty())
{
context->setHTTPHandlerName(introspection_handler_name);
/// The query a SQL-defined handler executes is the server's own stored text, parsed and validated
/// when the handler was created (possibly in a session with raised parser limits) and re-parsed
/// with unlimited limits on every reload (see `SQLDefinedHandlersMetadataStorage::readHandler`).
/// Parse it with unlimited depth and backtracks (`0` disables the limit) here too, so a handler
/// that was accepted at creation stays invokable under ordinary session limits instead of failing
/// each request until the caller raises `max_parser_depth` / `max_parser_backtracks` themselves.
/// The client controls only the typed query parameters, never the query text, and could raise
/// these settings per-request anyway (they are changeable under `readonly = 2`); `parseQuery`
/// still guards against stack overflow via `checkStackSize`.
context->setSetting("max_parser_depth", Field(0));
context->setSetting("max_parser_backtracks", Field(0));
}
/// === Authentication and user profile are applied first ===
/// Authentication has already happened above (line `authenticateUser`); makeQueryContext()
/// loads the user's default profile. Auth-related parameters (role) are applied immediately
/// after, so that the resulting settings/constraints are in effect before we process any
/// general settings.
auto roles = params.getAll("role");
if (!roles.empty())
context->setCurrentRoles(roles);
/// POST always allows modifying queries. For SQL-defined handlers (which set `introspection_handler_name`)
/// the mutating idempotent methods PUT and DELETE are allowed to modify data too, as decided per handler in
/// `makeSQLDefinedHandler`. Config-defined and built-in handlers keep the POST-only behavior.
setReadOnlyIfHTTPMethodIdempotent(context, request.getMethod(), /*allow_mutating_idempotent_methods=*/ !introspection_handler_name.empty());
/// Set the query id supplied by the user, if any, and also update the OpenTelemetry fields.
String query_id = params.get("query_id", request.get("X-ClickHouse-Query-Id", ""));
/// Sanitize query_id: remove ASCII control characters to prevent CRLF injection
/// into HTTP response headers (the query_id is reflected in X-ClickHouse-Query-Id).
std::erase_if(query_id, [](unsigned char c) { return isControlASCII(c) || c == 0x7F; });
context->setCurrentQueryId(query_id);
context->checkSettingsConstraints(settings_changes, SettingSource::QUERY);
context->applySettingsChanges(settings_changes);
const auto & settings = context->getSettingsRef();
/// === URL path parsing happens after settings are applied ===
/// This way the `http_allow_*_as_path` settings are read from the authenticated, profile-resolved
/// context (the same way any per-user setting works), not from server defaults. If the user
/// has all path features off, we skip path parsing entirely — the rest of the request is treated
/// exactly as it would be at the root URL.
HTTPPathInfo path_info;
bool any_path_feature_enabled = settings[Setting::http_allow_database_as_path]
|| settings[Setting::http_allow_table_as_file]
|| settings[Setting::http_allow_filters_as_path];
if (parsesHTTPPath() && any_path_feature_enabled)
{
const String & raw_uri = request.getURI();
String path_only = raw_uri;
auto qmark = path_only.find('?');
if (qmark != String::npos)
path_only = path_only.substr(0, qmark);
/// Keep `path_only` percent-encoded here. `parseHTTPPath` splits on '/' and then percent-decodes
/// each component, so an encoded slash (`%2F`) stays as data inside one component instead of being
/// turned into a component boundary — which `Poco::URI::getPath` (returning the fully decoded path)
/// would do, splitting legal encoded data into extra path components. The query string, if any, was
/// already stripped above.
/// If this handler is registered under a URL prefix, strip it so only the trailing portion
/// is interpreted as `database/table.format` (or filters / hive partitions). Require a
/// segment boundary so that prefix `/api/v1` does not also match `/api/v11/...`.
if (!url_prefix.empty() && hasUrlPrefixWithSegmentBoundary(path_only, url_prefix))
{
path_only = path_only.substr(url_prefix.size());
if (path_only.empty())
path_only = "/";
}
/// The legacy query endpoints — `/` and `/query`, plus the `?…` / `/?…` / `/query?…` forms the
/// routing filter (`addDefaultHandlersFactory`) claims as the query route — are not table-as-file
/// paths. Skip path parsing for them, so e.g. `GET /query?query=SELECT+1` keeps working when the
/// user has a path feature enabled; otherwise `parseHTTPPath` would read `query` as a table name
/// and the pre-check below would throw `UNKNOWN_TABLE` (or `implicit_table_at_top_level` would
/// rewrite a FROM-less query) before the SQL runs.
if (!path_only.empty() && path_only != "/" && path_only != "/query")
path_info = parseHTTPPath(
path_only,
settings[Setting::http_allow_database_as_path],
settings[Setting::http_allow_table_as_file],
settings[Setting::http_allow_filters_as_path]);
}
/// Resolve the current database from the path and the `database` setting, in that order.
/// If both are specified and differ, that's an error. We do this *before* `QueryScope::create`
/// — if `setCurrentDatabase` throws (e.g. the database doesn't exist), the exception unwinds
/// cleanly without leaving an in-flight query scope behind that would deadlock the response
/// buffers.
/// When the URL path supplied the database, we additionally append a hint about the closest
/// matching configured HTTP handler path (e.g. `/dashboard`) so a user who typed `/sashbord`
/// sees both the closest-handler suggestion and the closest-database-name suggestion.
{
/// The database explicitly supplied by *this request* via the `database` URL parameter or the
/// `X-ClickHouse-Database` header — it was collected into `settings_changes` and already
/// validated/applied above. A profile *default* for `database` is deliberately not treated as
/// request-supplied, so a path like `/db2/table` does not spuriously conflict with (and is not
/// blocked by) an inherited default — the path simply takes precedence over the default.
const Field * explicit_database_field = settings_changes.tryGet("database");
const String explicit_database = explicit_database_field ? explicit_database_field->safeGet<String>() : "";
String resolved_database = settings[Setting::database];
if (!path_info.database.empty())
{
if (!explicit_database.empty() && explicit_database != path_info.database)
throw Exception(ErrorCodes::BAD_ARGUMENTS,
"Conflicting database specification: '{}' in URL path vs '{}' in `database` setting.",
path_info.database, explicit_database);
/// A database from the URL path bypasses the `database` URL-parameter/header pipeline, so
/// run it through `checkSettingsConstraints` here too — otherwise a `database` constraint
/// (e.g. marked `const`, or restricted values) would protect the URL-parameter/header form
/// but not the `/database/table` path form. The path takes precedence over a profile default.
///
/// Apply it as the `database` setting as well (not just `setCurrentDatabase` below): `executeQuery`
/// re-applies a non-empty `database` setting via `setCurrentDatabase` after the query SETTINGS are
/// resolved, so an inherited profile default such as `database = 'db1'` would otherwise switch the
/// query back to `db1` after `/db2/...` had already set the current database — making unqualified
/// names resolve in the wrong database. Overwriting the setting here keeps the two in sync.
SettingsChanges database_change;
database_change.setSetting("database", path_info.database);
context->checkSettingsConstraints(database_change, SettingSource::QUERY);
context->applySettingsChanges(database_change);
resolved_database = path_info.database;
}
if (!resolved_database.empty())
{
try
{
context->setCurrentDatabase(resolved_database);
}
catch (Exception & e)
{
if (!path_info.database.empty() && path_hints)
{
auto handler_hints = path_hints->getHints("/" + path_info.database);
if (!handler_hints.empty())
e.addMessage("Or maybe HTTP handler {}?", handler_hints.front());
}
throw;
}
}
}
/// Initialize query scope, once query_id is initialized.
/// (To track as much allocations as possible)
query_scope = QueryScope::create(context);
/// Now we know the resolved settings. Decide what to do with unrecognized URL params:
/// - if http_allow_filters_as_unrecognized_url_parameters is true: treat them as filter expressions
/// - otherwise: pass them through as settings (which will likely fail with "unknown setting"),
/// preserving the original behavior.
std::vector<String> url_filters_from_unrecognized;
if (settings[Setting::http_allow_filters_as_unrecognized_url_parameters])
{
for (const auto & [key, value] : deferred_unrecognized_params)
{
String f = parseURLParameterAsFilter(key, value);
if (!f.empty())
url_filters_from_unrecognized.push_back(f);
}
}
else
{
SettingsChanges extra_changes;
for (const auto & [key, value] : deferred_unrecognized_params)
extra_changes.setSetting(key, value);
if (!extra_changes.empty())
{
context->checkSettingsConstraints(extra_changes, SettingSource::QUERY);
context->applySettingsChanges(extra_changes);
}
}
/// This parameter is used to tune the behavior of output formats (such as Native) for compatibility.
if (params.has("client_protocol_version"))
{
UInt64 version_param = parse<UInt64>(params.get("client_protocol_version"));
context->setClientProtocolVersion(version_param);
}
/// Apply compression from path (if no `compression` setting was specified explicitly).
SettingsChanges path_derived_changes;
if (!path_info.compression.empty())
{
/// Only a compression supplied by this request (URL parameter or header, collected into
/// `settings_changes` above) counts as an explicit override that can conflict with the path.
/// A value inherited from a user profile or session default is a fallback, and the extension
/// written in the path is per-request and more specific, so the path wins over it — the same
/// precedence rule as for `default_format` below.
const Field * request_compression = settings_changes.tryGet("compression");
const String current_compression = request_compression ? request_compression->safeGet<String>() : String{};
/// Compare the resolved `CompressionMethod`, not the raw strings: `chooseCompressionMethod`
/// treats `gzip`/`gz`, `zstd`/`zst`, `lzma`/`xz`, `brotli`/`br` etc. as aliases, so
/// `/hits.CSV.gz?compression=gzip` must not be rejected as a conflict.
const CompressionMethod request_compression_method = chooseCompressionMethod(path_info.filename_for_disposition, current_compression);
const CompressionMethod path_compression_method = chooseCompressionMethod({}, path_info.compression);
if (!current_compression.empty() && request_compression_method != path_compression_method)
throw Exception(ErrorCodes::BAD_ARGUMENTS,
"Conflicting compression: '{}' in URL path vs '{}' in `compression` setting.",
path_info.compression, current_compression);
/// Resolve `compression = 'auto'` against the path extension before storing it in the
/// context. The response writer does not otherwise have a filename to use as autodetection
/// context, so leaving `auto` there would produce an uncompressed response for `/t.CSV.gz`.
if (current_compression.empty() || Poco::icompare(current_compression, "auto") == 0)
path_derived_changes.setSetting("compression", path_info.compression);
}
/// Apply format from path (if no explicit `format`/`output_format` override exists).
/// "When there is a format from the file extension and there is also an explicit override, the override wins."
///
/// `default_format` is not an override: it is the fallback used when nothing else selects a format,
/// and it often comes from a user profile or a session-wide default rather than from this request.
/// The extension in the path is written per request and is more specific, so it wins over
/// `default_format` — but still loses to the explicit `format` / `output_format` overrides.
if (!path_info.format.empty())
{
const String & format_override = settings[Setting::format];
const String & output_format_override = settings[Setting::output_format];
if (format_override.empty() && output_format_override.empty())
{
/// Use as default_format so that queries with an explicit FORMAT clause still honor that clause.
path_derived_changes.setSetting("default_format", path_info.format);
}
}
if (!path_derived_changes.empty())
{
context->checkSettingsConstraints(path_derived_changes, SettingSource::QUERY);
context->applySettingsChanges(path_derived_changes);
}
/// The client can pass a HTTP header indicating supported compression method (gzip or deflate).
String http_response_compression_methods = request.get("Accept-Encoding", "");
CompressionMethod http_response_compression_method = CompressionMethod::None;
if (!http_response_compression_methods.empty())
http_response_compression_method = chooseHTTPCompressionMethod(http_response_compression_methods);
bool client_supports_http_compression = http_response_compression_method != CompressionMethod::None;
/// Client can pass a 'compress' flag in the query string. In this case the query result is
/// compressed using internal algorithm. This is not reflected in HTTP headers.
bool internal_compression = params.getParsedLast<bool>("compress", false);
/// If wait_end_of_query is specified, the whole result will be buffered.
/// First ~buffer_size bytes will be buffered in memory, the remaining bytes will be stored in temporary file.
auto buffer_size_http = settings[Setting::http_response_buffer_size];
/// setting overrides deprecated buffer_size parameter
if (!params.has("http_response_buffer_size"))
buffer_size_http = params.getParsedLast<size_t>("buffer_size", buffer_size_http);
bool wait_end_of_query = settings[Setting::http_wait_end_of_query];
/// setting overrides deprecated wait_end_of_query parameter
if (!params.has("http_wait_end_of_query"))
wait_end_of_query = params.getParsedLast<bool>("wait_end_of_query", wait_end_of_query);
bool enable_http_compression = params.getParsedLast<bool>("enable_http_compression", settings[Setting::enable_http_compression]);
Int64 http_zlib_compression_level
= params.getParsed<Int64>("http_zlib_compression_level", settings[Setting::http_zlib_compression_level]);
/// HTTP `Content-Encoding: snappy` is standardized to use the snappy framing format,
/// independent of the user-tunable `snappy_mode` (which controls generic `file()`/`url()` reads).
auto snappy_mode = SnappyMode::Framed;
used_output.out_holder =
std::make_shared<WriteBufferFromHTTPServerResponse>(
response,
request.getMethod() == HTTPRequest::HTTP_HEAD,
write_event);
used_output.out_maybe_compressed = used_output.out_holder;
used_output.out = used_output.out_holder;
if (client_supports_http_compression && enable_http_compression)
{
used_output.out_holder->setCompressionMethodHeader(http_response_compression_method);
used_output.wrap_compressed_holder = wrapWriteBufferWithCompressionMethod(
used_output.out.get(),
http_response_compression_method,
static_cast<int>(http_zlib_compression_level),
0,
snappy_mode,
DBMS_DEFAULT_BUFFER_SIZE,
nullptr,
0,
false);
used_output.out_maybe_compressed = used_output.wrap_compressed_holder;
used_output.out = used_output.wrap_compressed_holder;
}
/// Generic response-body compression from the `compression` setting (or URL path file extension).
/// This is independent of HTTP Content-Encoding — the bytes sent to the client are compressed
/// and the client is expected to decompress them.
const String & response_compression_name = settings[Setting::compression];
if (!response_compression_name.empty())
{
/// `chooseCompressionMethod` throws for an unrecognized hint and returns `None` for the recognized
/// no-op hints (`none`, or `auto` with no matching extension). Only wrap when a codec is actually
/// selected, so `compression = 'none'` disables a profile/default codec instead of being rejected.
CompressionMethod response_compression_method = chooseCompressionMethod({}, response_compression_name);
if (response_compression_method != CompressionMethod::None)
{
used_output.generic_compression_holder = wrapWriteBufferWithCompressionMethod(
used_output.out.get(),
response_compression_method,
static_cast<int>(http_zlib_compression_level),
0,
settings[Setting::snappy_mode],
DBMS_DEFAULT_BUFFER_SIZE,
nullptr,
0,
false);
used_output.out_maybe_compressed = used_output.generic_compression_holder;
used_output.out = used_output.generic_compression_holder;
}
}
if (internal_compression)
{
/// The frames are the same self-describing format as the native protocol's, so the codec comes from
/// the same setting. It must not come from the default codec for table data: that one is chosen for
/// how data sits on disk, and tying the two together silently changes, on every such change, what
/// each `compress=1` client has to be able to decode.
used_output.out_compressed_holder
= std::make_shared<CompressedWriteBuffer>(*used_output.out, chooseNetworkCompressionCodec(&settings));
used_output.out_maybe_compressed = used_output.out_compressed_holder;
used_output.out = used_output.out_compressed_holder;
}
if (buffer_size_http > 0 || wait_end_of_query)
{
CascadeWriteBuffer::WriteBufferPtrs cascade_buffers;
CascadeWriteBuffer::WriteBufferConstructors cascade_buffers_lazy;
if (buffer_size_http > 0)
cascade_buffers.emplace_back(std::make_shared<MemoryWriteBuffer>(buffer_size_http));
if (wait_end_of_query)
{
auto tmp_data = server.context()->getTempDataOnDisk();
cascade_buffers_lazy.emplace_back([tmp_data](const WriteBufferPtr &) -> WriteBufferPtr
{
return std::make_unique<TemporaryDataBuffer>(tmp_data);
});
}
else
{
auto push_memory_buffer_and_continue = [next_buffer = used_output.out] (const WriteBufferPtr & prev_buf)
{
auto * prev_memory_buffer = typeid_cast<MemoryWriteBuffer *>(prev_buf.get());
if (!prev_memory_buffer)
throw Exception(ErrorCodes::LOGICAL_ERROR, "Expected MemoryWriteBuffer");
auto rdbuf = prev_memory_buffer->tryGetReadBuffer();
copyData(*rdbuf, *next_buffer);
return next_buffer;
};
cascade_buffers_lazy.emplace_back(push_memory_buffer_and_continue);
}
used_output.out_delayed_and_compressed_holder = std::make_unique<CascadeWriteBuffer>(std::move(cascade_buffers), std::move(cascade_buffers_lazy));
used_output.out_maybe_delayed_and_compressed = used_output.out_delayed_and_compressed_holder;
}
else
{
used_output.out_maybe_delayed_and_compressed = used_output.out_maybe_compressed;
}
/// Request body can be compressed using algorithm specified in the Content-Encoding header.
String http_request_compression_method_str = request.get("Content-Encoding", "");
int zstd_window_log_max = static_cast<int>(context->getSettingsRef()[Setting::zstd_window_log_max]);
/// TODO check
/// input stream are hold inside in_post instance
auto in_post = wrapReadBufferWithCompressionMethod(
wrapReadBufferPointer(request.getStream()),
chooseCompressionMethod({}, http_request_compression_method_str),
zstd_window_log_max,
snappy_mode);
LOG_DEBUG(getLogger("HTTPServerRequest"), "creating in_post id {}", size_t(in_post.get()));
/// The data can also be compressed using incompatible internal algorithm. This is indicated by
/// 'decompress' query parameter.
std::unique_ptr<ReadBuffer> in_post_maybe_compressed;
bool is_in_post_compressed = false;
if (params.getParsedLast<bool>("decompress", false))
{
in_post_maybe_compressed = std::make_unique<CompressedReadBuffer>(std::move(in_post), /* allow_different_codecs_ = */ false, /* external_data_ = */ true);
is_in_post_compressed = true;
}
else
{
in_post_maybe_compressed = std::move(in_post);
}
/// NOTE: this may create pretty huge allocations that will not be accounted in trace_log,
/// because memory_profiler_sample_probability/memory_profiler_step are not applied yet,
/// they will be applied in ProcessList::insert() from executeQuery() itself.
const auto & raw_query = getQuery(request, params, context, *in_post_maybe_compressed);
/// Combine all HTTP filter sources into the `filter` setting. The query-construction settings
/// (`select`/`filter`/`order`/`sort`/`page`) are applied by the engine in `executeQuery`, on the
/// parsed AST — see `applyQueryConstructionSettings`. The HTTP interface only needs to assemble
/// the `filter` value here, because it has additional sources the engine does not: the existing
/// `filter` setting value, filters from the URL path, repeated `?filter=` parameters, and (when
/// enabled) unrecognized URL parameters, combined with `AND` in that order. `select`, `order`,
/// `sort` and `page` are already regular settings applied from the URL parameters, so the engine
/// reads them directly.
{
/// The filters that the HTTP request *adds* on top of the existing `filter` setting: filters
/// from the URL path, repeated `?filter=` parameters, and (when enabled) unrecognized URL
/// parameters.
std::vector<String> added_filters;
for (const auto & f : path_info.path_filters)
added_filters.push_back(f);
for (const auto & f : url_filters_from_params)
added_filters.push_back(f);
for (const auto & f : url_filters_from_unrecognized)
added_filters.push_back(f);
/// Only act when the request actually adds filters. Otherwise the existing `filter` setting
/// (e.g. a profile default) is left untouched and applied as-is by
/// `applyQueryConstructionSettings`. (Re-submitting the already-applied value through
/// `checkSettingsConstraints` would reject a `filter` constrained as `const` even when the
/// request changes nothing.)
if (!added_filters.empty())
{
String added_combined;
for (const auto & f : added_filters)
{
if (!added_combined.empty())
added_combined += " AND ";
added_combined += f;
}
/// Enforce the `filter` constraint on the added sources: build the full value (the
/// existing `filter` setting AND the added filters) and run `checkSettingsConstraints`,
/// so a profile that constrains `filter` (e.g. marks it `const`) blocks adding filters
/// via `?filter=` / the URL path. The check throws on violation; the value is not applied.
std::vector<String> all_filters;
if (!settings[Setting::filter].value.empty())
all_filters.push_back("(" + settings[Setting::filter].value + ")");
for (const auto & f : added_filters)
all_filters.push_back(f);
String full_filter;
for (const auto & f : all_filters)
{
if (!full_filter.empty())
full_filter += " AND ";
full_filter += f;
}
SettingsChanges filter_change;
filter_change.setSetting("filter", full_filter);
context->checkSettingsConstraints(filter_change, SettingSource::QUERY);
/// Stash the added filters in an overwrite-immune context channel (NOT the `filter`
/// setting) so they still apply — combined with `AND` — when the query carries its own
/// `SETTINGS filter = ...` clause, which would otherwise overwrite the `filter` setting.
context->setHTTPCombinedFilter(added_combined);
}
}
/// Determine base query: from URL path table, or from `query` param (raw_query).
String final_query = raw_query;
if (!path_info.table.empty())
{
/// `qualified_table` is the back-quoted `database.table` (or just `table`) from the URL path.
/// It is used both as SQL text spliced into a generated query (`SELECT * FROM <qualified_table>`)
/// and as the value of the `implicit_table_at_top_level` setting for a FROM-less query. The
/// analyzer parses that setting as a quoted compound identifier (see
/// `QueryTreeBuilder::buildJoinTree`), so back-quoting is required and correct: it lets a
/// database/table whose name needs quoting (e.g. `/weird-db/my-table`) and — crucially — a table
/// name that contains a literal dot (e.g. `/db/my.table` → `` `db`.`my.table` ``) resolve to the
/// right identifier parts instead of being split on every `.`.
String qualified_table;
if (!path_info.database.empty())
qualified_table = backQuoteIfNeed(path_info.database) + "." + backQuoteIfNeed(path_info.table);
else
qualified_table = backQuoteIfNeed(path_info.table);
/// Validate up-front that the table from the URL path actually exists, so a typo like
/// `/sashboards` produces a single clean response that combines the closest table-name
/// hint with the closest configured-handler hint (e.g. `/dashboard`). Without this check
/// the table-existence error would be raised later from query execution and would carry
/// only the table-name hint.
///
/// Skip the pre-check when the parsed table name still contains a dot: that means the
/// path parser tried to extract a format/compression extension and failed (e.g.
/// `/hits.Parquet` on a build that does not register Parquet). Deferring to the normal
/// query execution path preserves the existing response headers (Content-Disposition,
/// X-ClickHouse-Format) that other tests assert on.
///
/// Skip the pre-check when the user supplied an explicit query: either via the `query` URL
/// parameter (`raw_query`) or via a body. In those cases the path table is at
/// most a filename hint for `Content-Disposition`, or the source for
/// `implicit_table_at_top_level` (only applied to FROM-less queries). Forcing the path
/// table to exist would reject valid requests like `/foo.CSV?query=SELECT+1+FROM+other`
/// or `POST /db/path_table` with body `SELECT ... FROM other_table`.
bool request_has_body = feeds_request_body_to_query
&& (request.getChunkedTransferEncoding() || request.getContentLength64() > 0);
const String table_db = path_info.database.empty() ? context->getCurrentDatabase() : path_info.database;
bool table_name_is_simple = !path_info.table.contains('.');
if (table_name_is_simple && !table_db.empty() && raw_query.empty() && !request_has_body)
{
StorageID table_id(table_db, path_info.table);
if (!DatabaseCatalog::instance().isTableExist(table_id, context))
{
auto db_ptr = DatabaseCatalog::instance().tryGetDatabase(table_db);
TableNameHints table_hints(db_ptr, context);
auto table_name_hints = table_hints.getHints(path_info.table);
/// Format the message so it remains greppable by historical tests that look for
/// `There is no handle /X. Maybe you meant /Y` (02842, 03522). The leading clause
/// matches `NotFoundHandler` exactly; the trailing clauses add the database/table
/// context that the original handler did not have.
String message = fmt::format("There is no handle /{}.", path_info.table);
if (path_hints)
{
auto handler_hints = path_hints->getHints("/" + path_info.table);
if (!handler_hints.empty())
message += fmt::format(" Maybe you meant {}?", handler_hints.front());
}
message += fmt::format(" Or table {} (which does not exist)", table_id.getNameForLogs());
if (!table_name_hints.empty())
message += fmt::format(" - maybe you meant table {}", backQuoteIfNeed(table_name_hints.front()));
message += ".";
throw Exception(ErrorCodes::UNKNOWN_TABLE, "{}", message);
}
}
/// Always set implicit_table_at_top_level so a FROM-less SELECT (whether user-supplied
/// or auto-generated) picks up the table from the URL path.
SettingsChanges implicit_change;
implicit_change.setSetting("implicit_table_at_top_level", qualified_table);
context->checkSettingsConstraints(implicit_change, SettingSource::QUERY);
context->applySettingsChanges(implicit_change);
/// If there is no user-supplied query (URL param empty AND no body), generate a default one.
if (raw_query.empty() && !request_has_body)
final_query = "SELECT * FROM " + qualified_table;
}
/// The query-construction settings (`select`/`filter`/`order`/`sort`/`page`) are applied by the
/// engine (`executeQuery`) on the parsed AST, so the query text is not wrapped here. When the
/// SQL comes from the request body, `final_query` is empty and the body is concatenated below;
/// the engine then wraps the parsed body query just the same.
const String & query = final_query;
std::unique_ptr<ReadBuffer> in_param = std::make_unique<ReadBufferFromString>(query);
used_output.out_holder->setSendProgress(settings[Setting::send_progress_in_http_headers]);
used_output.out_holder->setSendProgressInterval(settings[Setting::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.