MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / checkAndNormalizeHeaders

Method checkAndNormalizeHeaders

src/Common/HTTPHeaderFilter.cpp:16–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14}
15
16void HTTPHeaderFilter::checkAndNormalizeHeaders(HTTPHeaderEntries & entries) const
17{
18 std::lock_guard guard(mutex);
19
20 for (auto & entry : entries)
21 {
22 if (entry.name.contains('\n') || entry.value.contains('\n'))
23 throw Exception(ErrorCodes::BAD_ARGUMENTS, "HTTP header \"{}\" has invalid character", entry.name);
24 /// Strip whitespace and control characters from header name for validation
25 std::string & normalized_name = entry.name;
26 normalized_name.erase(
27 std::remove_if(
28 normalized_name.begin(),
29 normalized_name.end(),
30 [](char c) { return std::iscntrl(static_cast<unsigned char>(c)) || std::isspace(static_cast<unsigned char>(c)); }),
31 normalized_name.end());
32
33 if (forbidden_headers.contains(normalized_name))
34 throw Exception(ErrorCodes::BAD_ARGUMENTS, "HTTP header \"{}\" is forbidden in configuration file, "
35 "see <http_forbid_headers>", entry.name);
36
37 for (const auto & header_regex : forbidden_headers_regexp)
38 if (re2::RE2::FullMatch(normalized_name, header_regex))
39 throw Exception(ErrorCodes::BAD_ARGUMENTS, "HTTP header \"{}\" is forbidden in configuration file, "
40 "see <http_forbid_headers>", entry.name);
41 }
42}
43
44void HTTPHeaderFilter::setValuesFromConfig(const Poco::Util::AbstractConfiguration & config)
45{

Callers 7

StorageURLClusterMethod · 0.80
StorageURLMethod · 0.80
checkMethod · 0.80
getClientFunction · 0.80
registerDatabaseDataLakeFunction · 0.80
TEST_FFunction · 0.80

Calls 5

ExceptionClass · 0.70
containsMethod · 0.45
eraseMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by 1

TEST_FFunction · 0.64