mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 01:51:59 +00:00
Merge branch 'query_in_form_data' of https://github.com/stavrolia/ClickHouse into stavrolia-query_in_form_data
This commit is contained in:
commit
d4eefc414c
@ -421,14 +421,26 @@ void HTTPHandler::processQuery(
|
||||
|
||||
std::unique_ptr<ReadBuffer> in;
|
||||
|
||||
// Used in case of POST request with form-data, but it not to be expectd to be deleted after that scope
|
||||
std::string full_query;
|
||||
|
||||
/// Support for "external data for query processing".
|
||||
if (startsWith(request.getContentType().data(), "multipart/form-data"))
|
||||
{
|
||||
in = std::move(in_param);
|
||||
ExternalTablesHandler handler(context, params);
|
||||
|
||||
/// Params are of both form params POST and uri (GET params)
|
||||
params.load(request, istr, handler);
|
||||
|
||||
for (const auto & it : params)
|
||||
{
|
||||
if (it.first == "query")
|
||||
{
|
||||
full_query += it.second;
|
||||
}
|
||||
}
|
||||
in = std::make_unique<ReadBufferFromString>(full_query);
|
||||
|
||||
/// Erase unneeded parameters to avoid confusing them later with context settings or query
|
||||
/// parameters.
|
||||
for (const auto & it : handler.names)
|
||||
|
3
dbms/tests/queries/0_stateless/00625_query_in_form_data.reference
Executable file
3
dbms/tests/queries/0_stateless/00625_query_in_form_data.reference
Executable file
@ -0,0 +1,3 @@
|
||||
1
|
||||
1 Hello
|
||||
2 World
|
10
dbms/tests/queries/0_stateless/00625_query_in_form_data.sh
Executable file
10
dbms/tests/queries/0_stateless/00625_query_in_form_data.sh
Executable file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
. $CURDIR/../shell_config.sh
|
||||
|
||||
${CLICKHOUSE_CURL} ${CLICKHOUSE_URL}?query="select" -X POST -F "query= 1;" 2>/dev/null
|
||||
|
||||
|
||||
echo -ne '1,Hello\n2,World\n' | ${CLICKHOUSE_CURL} -sSF 'file=@-' "${CLICKHOUSE_URL}?file_format=CSV&file_types=UInt8,String&query=SELE" -X POST -F "query=CT * FROM file" 2>/dev/null
|
Loading…
Reference in New Issue
Block a user