Implement zstd decompression
Given the size of Redfish schemas these days, it would be nice to be
able to store them on disk in a zstd format. Unfortunately, not all
clients support zstd at this time.
This commit implements reading of zstd files from disk, as well as
decompressing zstd in the case where the client does not support zstd as
a return type.
Tested:
Implanted an artificial zstd file into the system, and observed correct
decompression both with an allow-encoding header of empty string and
zstd.
Change-Id: I8b631bb943de99002fdd6745340aec010ee591ff
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/http/http_connection.hpp b/http/http_connection.hpp
index 807ca35..0c8ad0e 100644
--- a/http/http_connection.hpp
+++ b/http/http_connection.hpp
@@ -383,14 +383,16 @@
return;
}
req->session = userSession;
- accept = req->getHeaderValue("Accept");
+ using boost::beast::http::field;
+ accept = req->getHeaderValue(field::accept);
+ acceptEncoding = req->getHeaderValue(field::accept_encoding);
// Fetch the client IP address
req->ipAddress = ip;
// Check for HTTP version 1.1.
if (req->version() == 11)
{
- if (req->getHeaderValue(boost::beast::http::field::host).empty())
+ if (req->getHeaderValue(field::host).empty())
{
res.result(boost::beast::http::status::bad_request);
completeRequest(res);
@@ -490,7 +492,7 @@
res = std::move(thisRes);
res.keepAlive(keepAlive);
- completeResponseFields(accept, res);
+ completeResponseFields(accept, acceptEncoding, res);
res.addHeader(boost::beast::http::field::date, getCachedDateStr());
doWrite();
@@ -931,6 +933,8 @@
std::shared_ptr<crow::Request> req;
std::string accept;
std::string http2settings;
+ std::string acceptEncoding;
+
crow::Response res;
std::shared_ptr<persistent_data::UserSession> userSession;