Check for duplicates

This commit is contained in:
Alexey Milovidov 2024-11-30 22:14:42 +01:00
parent 87601d461f
commit bdff47973a
3 changed files with 7 additions and 1 deletions

View File

@ -1705,7 +1705,8 @@ void executeQuery(
|| std::find_if(value.begin(), value.end(), isControlASCII) != value.end())
throw Exception(ErrorCodes::BAD_ARGUMENTS, "The values of the `additional_http_headers` cannot contain ASCII control characters");
result_details.additional_headers.emplace(key, value);
if (!result_details.additional_headers.emplace(key, value).second)
throw Exception(ErrorCodes::BAD_ARGUMENTS, "There are duplicate entries in the `additional_http_headers` setting");
}
}

View File

@ -13,3 +13,5 @@ Check that we can override it:
It does not allow bad characters:
BAD_ARGUMENTS
BAD_ARGUMENTS
It does not let duplicate entries:
BAD_ARGUMENTS

View File

@ -19,3 +19,6 @@ ${CLICKHOUSE_CURL} -sS --globoff -v "http://localhost:8123/?http_response_header
echo "It does not allow bad characters:"
${CLICKHOUSE_CURL} -sS --globoff -v "http://localhost:8123/" -d "SELECT 1 SETTINGS http_response_headers = \$\${'My-New-Header':'Hello,\n\nworld.'}\$\$" 2>&1 | grep -o -F 'BAD_ARGUMENTS'
${CLICKHOUSE_CURL} -sS --globoff -v "http://localhost:8123/" -d "SELECT 1 SETTINGS http_response_headers = \$\${'My\rNew-Header':'Hello, world.'}\$\$" 2>&1 | grep -o -F 'BAD_ARGUMENTS'
echo "It does not let duplicate entries:"
${CLICKHOUSE_CURL} -sS --globoff -v "http://localhost:8123/" -d "SELECT 1 SETTINGS http_response_headers = \$\${'a':'b','a':'c'}\$\$" 2>&1 | grep -o -F 'BAD_ARGUMENTS'