diff options
author | Ed Tanous <edtanous@google.com> | 2023-07-18 20:07:23 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2024-01-19 22:43:50 +0300 |
commit | 18f8f608b966c802b3e2a389e3c1ec5a1fd9407b (patch) | |
tree | 89684cb74b7492ffc1e34fb8e3a004de18726071 /http | |
parent | f86bcc875a496b3c321a4ed102579a4031617800 (diff) | |
download | bmcweb-18f8f608b966c802b3e2a389e3c1ec5a1fd9407b.tar.xz |
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 <edtanous@google.com>
Diffstat (limited to 'http')
-rw-r--r-- | http/http2_connection.hpp | 1 | ||||
-rw-r--r-- | http/http_connection.hpp | 8 | ||||
-rw-r--r-- | http/parsing.hpp | 17 | ||||
-rw-r--r-- | http/server_sent_event.hpp | 1 |
4 files changed, 15 insertions, 12 deletions
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 <boost/algorithm/string/predicate.hpp> #include <boost/asio/io_context.hpp> #include <boost/asio/ip/tcp.hpp> #include <boost/asio/ssl/stream.hpp> 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 <boost/algorithm/string/predicate.hpp> #include <boost/asio/io_context.hpp> #include <boost/asio/ip/tcp.hpp> #include <boost/asio/ssl/stream.hpp> @@ -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 <boost/algorithm/string/predicate.hpp> #include <nlohmann/json.hpp> +#include <algorithm> +#include <cctype> #include <string_view> 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 <boost/algorithm/string/predicate.hpp> #include <boost/asio/buffer.hpp> #include <boost/asio/steady_timer.hpp> #include <boost/beast/core/multi_buffer.hpp> |