diff options
Diffstat (limited to 'http/http_response.hpp')
-rw-r--r-- | http/http_response.hpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/http/http_response.hpp b/http/http_response.hpp index 3c2a3f98b9..58a802915b 100644 --- a/http/http_response.hpp +++ b/http/http_response.hpp @@ -4,6 +4,7 @@ #include <boost/beast/http/message.hpp> #include <boost/beast/http/string_body.hpp> +#include <utils/hex_utils.hpp> #include <optional> #include <string> @@ -125,6 +126,17 @@ struct Response void end() { + // Only set etag if this request succeeded + if (result() == boost::beast::http::status::ok) + { + // and the json response isn't empty + if (!jsonValue.empty()) + { + size_t hashval = std::hash<nlohmann::json>{}(jsonValue); + std::string hexVal = "\"" + intToHexString(hashval, 8) + "\""; + addHeader(boost::beast::http::field::etag, hexVal); + } + } if (completed) { BMCWEB_LOG_ERROR << this << " Response was ended twice"; |