From 18f8f608b966c802b3e2a389e3c1ec5a1fd9407b Mon Sep 17 00:00:00 2001 From: Ed Tanous Date: Tue, 18 Jul 2023 10:07:23 -0700 Subject: Remove some boost includes The less we rely on boost, and more on std algorithms, the less people have to look up, and the more likely that our code will deduplicate. Replace all uses of boost::algorithms with std alternatives. Tested: Redfish Service Validator passes. Change-Id: I8a26f39b5709adc444b4178e92f5f3c7b988b05b Signed-off-by: Ed Tanous --- http/http2_connection.hpp | 1 - http/http_connection.hpp | 8 ++++---- http/parsing.hpp | 17 +++++++++++------ http/server_sent_event.hpp | 1 - 4 files changed, 15 insertions(+), 12 deletions(-) (limited to 'http') diff --git a/http/http2_connection.hpp b/http/http2_connection.hpp index ee3a218807..95d184e67b 100644 --- a/http/http2_connection.hpp +++ b/http/http2_connection.hpp @@ -12,7 +12,6 @@ #include "ssl_key_handler.hpp" #include "utility.hpp" -#include #include #include #include diff --git a/http/http_connection.hpp b/http/http_connection.hpp index 7ea0ac6d01..196dc5fa73 100644 --- a/http/http_connection.hpp +++ b/http/http_connection.hpp @@ -10,9 +10,9 @@ #include "logging.hpp" #include "mutual_tls.hpp" #include "ssl_key_handler.hpp" +#include "str_utility.hpp" #include "utility.hpp" -#include #include #include #include @@ -288,10 +288,10 @@ class Connection : bool isSse = isContentTypeAllowed(req->getHeaderValue("Accept"), http_helpers::ContentType::EventStream, false); + std::string_view upgradeType( + thisReq.getHeaderValue(boost::beast::http::field::upgrade)); if ((thisReq.isUpgrade() && - boost::iequals( - thisReq.getHeaderValue(boost::beast::http::field::upgrade), - "websocket")) || + bmcweb::asciiIEquals(upgradeType, "websocket")) || isSse) { asyncResp->res.setCompleteRequestHandler( diff --git a/http/parsing.hpp b/http/parsing.hpp index 839b51cae1..9a19baf452 100644 --- a/http/parsing.hpp +++ b/http/parsing.hpp @@ -2,10 +2,12 @@ #include "http/http_request.hpp" #include "logging.hpp" +#include "str_utility.hpp" -#include #include +#include +#include #include enum class JsonParseResult @@ -15,14 +17,17 @@ enum class JsonParseResult Success, }; +inline bool isJsonContentType(std::string_view contentType) +{ + return bmcweb::asciiIEquals(contentType, "application/json") || + bmcweb::asciiIEquals(contentType, "application/json; charset=utf-8"); +} + inline JsonParseResult parseRequestAsJson(const crow::Request& req, nlohmann::json& jsonOut) { - std::string_view contentType = - req.getHeaderValue(boost::beast::http::field::content_type); - - if (!boost::iequals(contentType, "application/json") && - !boost::iequals(contentType, "application/json; charset=utf-8")) + if (!isJsonContentType( + req.getHeaderValue(boost::beast::http::field::content_type))) { BMCWEB_LOG_WARNING("Failed to parse content type on request"); #ifndef BMCWEB_INSECURE_IGNORE_CONTENT_TYPE diff --git a/http/server_sent_event.hpp b/http/server_sent_event.hpp index 49002f60db..f4ad21a69f 100644 --- a/http/server_sent_event.hpp +++ b/http/server_sent_event.hpp @@ -3,7 +3,6 @@ #include "http_request.hpp" #include "http_response.hpp" -#include #include #include #include -- cgit v1.2.3