summaryrefslogtreecommitdiff
path: root/http/parsing.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'http/parsing.hpp')
-rw-r--r--http/parsing.hpp17
1 files changed, 11 insertions, 6 deletions
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