diff options
author | Ed Tanous <edtanous@google.com> | 2023-02-15 01:50:33 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2023-03-11 03:50:32 +0300 |
commit | 98fe740b59a96fd4d4232655f820da168129f090 (patch) | |
tree | b75d41861aad9bb386409d3d7957da656d437346 /http/http_request.hpp | |
parent | f96597b530ef280534a21c1672974ecae4f01493 (diff) | |
download | bmcweb-98fe740b59a96fd4d4232655f820da168129f090.tar.xz |
Remove fields member from Request
Per cpp core guidelines, we should be returning this via a function
call, not a direct member variable. Doing this also improves the
safety, as we don't have to remember to move the references over in a
move.
Tested: Tested as part of top patch in series.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I837d6fd277ffa076ba5425003d6e6ee79204d014
Diffstat (limited to 'http/http_request.hpp')
-rw-r--r-- | http/http_request.hpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/http/http_request.hpp b/http/http_request.hpp index 405db870fa..3a36a119c2 100644 --- a/http/http_request.hpp +++ b/http/http_request.hpp @@ -20,7 +20,6 @@ namespace crow struct Request { boost::beast::http::request<boost::beast::http::string_body> req; - boost::beast::http::fields& fields; std::string_view url{}; boost::urls::url_view urlView{}; @@ -37,7 +36,7 @@ struct Request Request(boost::beast::http::request<boost::beast::http::string_body> reqIn, std::error_code& ec) : req(std::move(reqIn)), - fields(req.base()), body(req.body()) + body(req.body()) { if (!setUrlInfo()) { @@ -46,18 +45,16 @@ struct Request } Request(const Request& other) : - req(other.req), fields(req.base()), isSecure(other.isSecure), - body(req.body()), ioService(other.ioService), - ipAddress(other.ipAddress), session(other.session), - userRole(other.userRole) + req(other.req), isSecure(other.isSecure), body(req.body()), + ioService(other.ioService), ipAddress(other.ipAddress), + session(other.session), userRole(other.userRole) { setUrlInfo(); } Request(Request&& other) noexcept : - req(std::move(other.req)), fields(req.base()), isSecure(other.isSecure), - body(req.body()), ioService(other.ioService), - ipAddress(std::move(other.ipAddress)), + req(std::move(other.req)), isSecure(other.isSecure), body(req.body()), + ioService(other.ioService), ipAddress(std::move(other.ipAddress)), session(std::move(other.session)), userRole(std::move(other.userRole)) { setUrlInfo(); @@ -92,6 +89,11 @@ struct Request return req.target(); } + const boost::beast::http::fields& fields() const + { + return req.base(); + } + bool target(std::string_view target) { req.target(target); |