mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-10 09:32:06 +00:00
Merge pull request #58060 from ClickHouse/non_post_request_shouldbe_readonly
Non post request should be readonly
This commit is contained in:
commit
5b6d171145
@ -729,8 +729,8 @@ void HTTPHandler::processQuery(
|
||||
/// to some other value.
|
||||
const auto & settings = context->getSettingsRef();
|
||||
|
||||
/// Only readonly queries are allowed for HTTP GET requests.
|
||||
if (request.getMethod() == HTTPServerRequest::HTTP_GET)
|
||||
/// Anything else beside HTTP POST should be readonly queries.
|
||||
if (request.getMethod() != HTTPServerRequest::HTTP_POST)
|
||||
{
|
||||
if (settings.readonly == 0)
|
||||
context->setSetting("readonly", 2);
|
||||
|
@ -0,0 +1,2 @@
|
||||
Cannot execute query in readonly mode
|
||||
Internal Server Error
|
16
tests/queries/0_stateless/02947_non_post_request_should_be_readonly.sh
Executable file
16
tests/queries/0_stateless/02947_non_post_request_should_be_readonly.sh
Executable file
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
# Tags: no-parallel
|
||||
|
||||
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
# shellcheck source=../shell_config.sh
|
||||
. "$CUR_DIR"/../shell_config.sh
|
||||
|
||||
# This should fail
|
||||
${CLICKHOUSE_CURL} -X GET -sS "${CLICKHOUSE_URL}&session_id=${SESSION_ID}&query=CREATE+DATABASE+non_post_request_test" | grep -o "Cannot execute query in readonly mode"
|
||||
|
||||
# This should fail
|
||||
${CLICKHOUSE_CURL} --head -sS "${CLICKHOUSE_URL}&session_id=${SESSION_ID}&query=CREATE+DATABASE+non_post_request_test" | grep -o "Internal Server Error"
|
||||
|
||||
# This should pass - but will throw error "non_post_request_test already exists" if the database was created by any of the above requests.
|
||||
${CLICKHOUSE_CURL} -X POST -sS "${CLICKHOUSE_URL}&session_id=${SESSION_ID}" -d 'CREATE DATABASE non_post_request_test'
|
||||
${CLICKHOUSE_CURL} -X POST -sS "${CLICKHOUSE_URL}&session_id=${SESSION_ID}" -d 'DROP DATABASE non_post_request_test'
|
Loading…
Reference in New Issue
Block a user