summaryrefslogtreecommitdiff
path: root/http
diff options
context:
space:
mode:
Diffstat (limited to 'http')
-rw-r--r--http/http2_connection.hpp28
-rw-r--r--http/http_response.hpp6
2 files changed, 23 insertions, 11 deletions
diff --git a/http/http2_connection.hpp b/http/http2_connection.hpp
index 4b2d186f07..2c60c1268e 100644
--- a/http/http2_connection.hpp
+++ b/http/http2_connection.hpp
@@ -167,17 +167,18 @@ class HTTP2Connection :
close();
return -1;
}
- Response& thisRes = it->second.res;
- thisRes = std::move(completedRes);
- crow::Request& thisReq = it->second.req;
- std::vector<nghttp2_nv> hdr;
+ Http2StreamData& stream = it->second;
+ Response& res = stream.res;
+ res = std::move(completedRes);
+ crow::Request& thisReq = stream.req;
- completeResponseFields(thisReq, thisRes);
- thisRes.addHeader(boost::beast::http::field::date, getCachedDateStr());
- thisRes.preparePayload();
+ completeResponseFields(thisReq, res);
+ res.addHeader(boost::beast::http::field::date, getCachedDateStr());
+ res.preparePayload();
- boost::beast::http::fields& fields = thisRes.fields();
- std::string code = std::to_string(thisRes.resultInt());
+ boost::beast::http::fields& fields = res.fields();
+ std::string code = std::to_string(res.resultInt());
+ std::vector<nghttp2_nv> hdr;
hdr.emplace_back(
headerFromStringViews(":status", code, NGHTTP2_NV_FLAG_NONE));
for (const boost::beast::http::fields::value_type& header : fields)
@@ -185,8 +186,6 @@ class HTTP2Connection :
hdr.emplace_back(headerFromStringViews(
header.name_string(), header.value(), NGHTTP2_NV_FLAG_NONE));
}
- Http2StreamData& stream = it->second;
- crow::Response& res = stream.res;
http::response<bmcweb::HttpBody>& fbody = res.response;
stream.writer.emplace(fbody.base(), fbody.body());
@@ -279,6 +278,13 @@ class HTTP2Connection :
else
#endif // BMCWEB_INSECURE_DISABLE_AUTHX
{
+ std::string_view expected = thisReq.getHeaderValue(
+ boost::beast::http::field::if_none_match);
+ BMCWEB_LOG_DEBUG("Setting expected hash {}", expected);
+ if (!expected.empty())
+ {
+ asyncResp->res.setExpectedHash(expected);
+ }
handler->handle(thisReq, asyncResp);
}
return 0;
diff --git a/http/http_response.hpp b/http/http_response.hpp
index c93d60d685..18266ec93d 100644
--- a/http/http_response.hpp
+++ b/http/http_response.hpp
@@ -80,6 +80,7 @@ struct Response
}
response = std::move(r.response);
jsonValue = std::move(r.jsonValue);
+ expectedHash = std::move(r.expectedHash);
// Only need to move completion handler if not already completed
// Note, there are cases where we might move out of a Response object
@@ -144,6 +145,11 @@ struct Response
return fields()[key];
}
+ std::string_view getHeaderValue(boost::beast::http::field key) const
+ {
+ return fields()[key];
+ }
+
void keepAlive(bool k)
{
response.keep_alive(k);