mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-30 11:32:03 +00:00
Add new HTTP compression methods
This commit is contained in:
parent
011748e431
commit
99dc396c77
@ -55,6 +55,32 @@ std::string toContentEncodingName(CompressionMethod method)
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
CompressionMethod chooseHTTPCompressionMethod(const std::string & list)
|
||||
{
|
||||
/// If client supports brotli - it's preferred.
|
||||
/// Both gzip and deflate are supported. If the client supports both, gzip is preferred.
|
||||
/// NOTE parsing of the list of methods is slightly incorrect.
|
||||
|
||||
if (std::string::npos != list.find("br"))
|
||||
return CompressionMethod::Brotli;
|
||||
else if (std::string::npos != list.find("gzip"))
|
||||
return CompressionMethod::Gzip;
|
||||
else if (std::string::npos != list.find("deflate"))
|
||||
return CompressionMethod::Zlib;
|
||||
else if (std::string::npos != list.find("xz"))
|
||||
return CompressionMethod::Xz;
|
||||
else if (std::string::npos != list.find("zstd"))
|
||||
return CompressionMethod::Zstd;
|
||||
else if (std::string::npos != list.find("lz4"))
|
||||
return CompressionMethod::Lz4;
|
||||
else if (std::string::npos != list.find("snappy"))
|
||||
return CompressionMethod::Snappy;
|
||||
else if (std::string::npos != list.find("bz2"))
|
||||
return CompressionMethod::Bzip2;
|
||||
else
|
||||
return CompressionMethod::None;
|
||||
}
|
||||
|
||||
CompressionMethod chooseCompressionMethod(const std::string & path, const std::string & hint)
|
||||
{
|
||||
std::string file_extension;
|
||||
|
@ -46,6 +46,10 @@ std::string toContentEncodingName(CompressionMethod method);
|
||||
*/
|
||||
CompressionMethod chooseCompressionMethod(const std::string & path, const std::string & hint);
|
||||
|
||||
/** Choose a compression method from HTTP header list of supported compression methods.
|
||||
*/
|
||||
CompressionMethod chooseHTTPCompressionMethod(const std::string & list)
|
||||
|
||||
/// Get a range of the valid compression levels for the compression method.
|
||||
std::pair<uint64_t, uint64_t> getCompressionLevelRange(const CompressionMethod & method);
|
||||
|
||||
|
@ -542,22 +542,7 @@ void HTTPHandler::processQuery(
|
||||
CompressionMethod http_response_compression_method = CompressionMethod::None;
|
||||
|
||||
if (!http_response_compression_methods.empty())
|
||||
{
|
||||
/// If client supports brotli - it's preferred.
|
||||
/// Both gzip and deflate are supported. If the client supports both, gzip is preferred.
|
||||
/// NOTE parsing of the list of methods is slightly incorrect.
|
||||
|
||||
if (std::string::npos != http_response_compression_methods.find("br"))
|
||||
http_response_compression_method = CompressionMethod::Brotli;
|
||||
else if (std::string::npos != http_response_compression_methods.find("gzip"))
|
||||
http_response_compression_method = CompressionMethod::Gzip;
|
||||
else if (std::string::npos != http_response_compression_methods.find("deflate"))
|
||||
http_response_compression_method = CompressionMethod::Zlib;
|
||||
else if (std::string::npos != http_response_compression_methods.find("xz"))
|
||||
http_response_compression_method = CompressionMethod::Xz;
|
||||
else if (std::string::npos != http_response_compression_methods.find("zstd"))
|
||||
http_response_compression_method = CompressionMethod::Zstd;
|
||||
}
|
||||
http_response_compression_method = chooseHTTPCompressionMethod(http_response_compression_methods);
|
||||
|
||||
bool client_supports_http_compression = http_response_compression_method != CompressionMethod::None;
|
||||
|
||||
|
@ -41,18 +41,7 @@ responseWriteBuffer(HTTPServerRequest & request, HTTPServerResponse & response,
|
||||
CompressionMethod http_response_compression_method = CompressionMethod::None;
|
||||
|
||||
if (!http_response_compression_methods.empty())
|
||||
{
|
||||
/// If client supports brotli - it's preferred.
|
||||
/// Both gzip and deflate are supported. If the client supports both, gzip is preferred.
|
||||
/// NOTE parsing of the list of methods is slightly incorrect.
|
||||
|
||||
if (std::string::npos != http_response_compression_methods.find("br"))
|
||||
http_response_compression_method = CompressionMethod::Brotli;
|
||||
else if (std::string::npos != http_response_compression_methods.find("gzip"))
|
||||
http_response_compression_method = CompressionMethod::Gzip;
|
||||
else if (std::string::npos != http_response_compression_methods.find("deflate"))
|
||||
http_response_compression_method = CompressionMethod::Zlib;
|
||||
}
|
||||
http_response_compression_method = chooseHTTPCompressionMethod(http_response_compression_methods);
|
||||
|
||||
bool client_supports_http_compression = http_response_compression_method != CompressionMethod::None;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user