summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--http/http2_connection.hpp4
-rw-r--r--http/http_request.hpp9
-rw-r--r--http/websocket.hpp3
-rw-r--r--redfish-core/include/query.hpp8
-rw-r--r--test/redfish-core/include/utils/json_utils_test.cpp8
5 files changed, 21 insertions, 11 deletions
diff --git a/http/http2_connection.hpp b/http/http2_connection.hpp
index 4b1b2dcb91..8416ff738b 100644
--- a/http/http2_connection.hpp
+++ b/http/http2_connection.hpp
@@ -434,7 +434,7 @@ class HTTP2Connection :
close();
return -1;
}
- thisReq.req.method(verb);
+ thisReq.method(verb);
}
else if (nameSv == ":scheme")
{
@@ -442,7 +442,7 @@ class HTTP2Connection :
}
else
{
- thisReq.req.set(nameSv, valueSv);
+ thisReq.addHeader(nameSv, valueSv);
}
return 0;
}
diff --git a/http/http_request.hpp b/http/http_request.hpp
index a3c8fd8d0e..53f51e68fd 100644
--- a/http/http_request.hpp
+++ b/http/http_request.hpp
@@ -80,6 +80,10 @@ struct Request
{
return req.method();
}
+ void method(boost::beast::http::verb verb)
+ {
+ return req.method(verb);
+ }
std::string_view getHeaderValue(std::string_view key) const
{
@@ -91,6 +95,11 @@ struct Request
return req[key];
}
+ void clearHeader(boost::beast::http::field key)
+ {
+ req.erase(key);
+ }
+
std::string_view methodString() const
{
return req.method_string();
diff --git a/http/websocket.hpp b/http/websocket.hpp
index d232c02330..2ef8412886 100644
--- a/http/websocket.hpp
+++ b/http/websocket.hpp
@@ -92,7 +92,8 @@ class ConnectionImpl : public Connection
BMCWEB_LOG_DEBUG("starting connection {}", logPtr(this));
using bf = boost::beast::http::field;
- std::string protocolHeader = req.req[bf::sec_websocket_protocol];
+ std::string protocolHeader{
+ req.getHeaderValue(bf::sec_websocket_protocol)};
ws.set_option(boost::beast::websocket::stream_base::decorator(
[session{session},
diff --git a/redfish-core/include/query.hpp b/redfish-core/include/query.hpp
index 5962093bfc..e68b89ae00 100644
--- a/redfish-core/include/query.hpp
+++ b/redfish-core/include/query.hpp
@@ -46,7 +46,7 @@ inline void
return;
}
// Restart the request without if-match
- req.req.erase(boost::beast::http::field::if_match);
+ req.clearHeader(boost::beast::http::field::if_match);
BMCWEB_LOG_DEBUG("Restarting request");
app.handle(req, asyncResp);
}
@@ -74,9 +74,9 @@ inline bool handleIfMatch(crow::App& app, const crow::Request& req,
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/If-Match
return true;
}
- if (req.req.method() != boost::beast::http::verb::patch &&
- req.req.method() != boost::beast::http::verb::post &&
- req.req.method() != boost::beast::http::verb::delete_)
+ if (req.method() != boost::beast::http::verb::patch &&
+ req.method() != boost::beast::http::verb::post &&
+ req.method() != boost::beast::http::verb::delete_)
{
messages::preconditionFailed(asyncResp->res);
return false;
diff --git a/test/redfish-core/include/utils/json_utils_test.cpp b/test/redfish-core/include/utils/json_utils_test.cpp
index 9245f25d87..5ef80eeba6 100644
--- a/test/redfish-core/include/utils/json_utils_test.cpp
+++ b/test/redfish-core/include/utils/json_utils_test.cpp
@@ -297,7 +297,7 @@ TEST(ReadJsonPatch, ValidElementsReturnsTrueResponseOkValuesUnpackedCorrectly)
crow::Request req("{\"integer\": 1}", ec);
// Ignore errors intentionally
- req.req.set(boost::beast::http::field::content_type, "application/json");
+ req.addHeader(boost::beast::http::field::content_type, "application/json");
int64_t integer = 0;
ASSERT_TRUE(readJsonPatch(req, res, "integer", integer));
@@ -324,7 +324,7 @@ TEST(ReadJsonPatch, OdataIgnored)
crow::Response res;
std::error_code ec;
crow::Request req(R"({"@odata.etag": "etag", "integer": 1})", ec);
- req.req.set(boost::beast::http::field::content_type, "application/json");
+ req.addHeader(boost::beast::http::field::content_type, "application/json");
// Ignore errors intentionally
std::optional<int64_t> integer = 0;
@@ -352,7 +352,7 @@ TEST(ReadJsonAction, ValidElementsReturnsTrueResponseOkValuesUnpackedCorrectly)
crow::Response res;
std::error_code ec;
crow::Request req("{\"integer\": 1}", ec);
- req.req.set(boost::beast::http::field::content_type, "application/json");
+ req.addHeader(boost::beast::http::field::content_type, "application/json");
// Ignore errors intentionally
int64_t integer = 0;
@@ -367,7 +367,7 @@ TEST(ReadJsonAction, EmptyObjectReturnsTrueResponseOk)
crow::Response res;
std::error_code ec;
crow::Request req({"{}"}, ec);
- req.req.set(boost::beast::http::field::content_type, "application/json");
+ req.addHeader(boost::beast::http::field::content_type, "application/json");
// Ignore errors intentionally
std::optional<int64_t> integer = 0;