summaryrefslogtreecommitdiff
path: root/redfish-core/src/utils
diff options
context:
space:
mode:
Diffstat (limited to 'redfish-core/src/utils')
-rw-r--r--redfish-core/src/utils/json_utils.cpp16
1 files changed, 13 insertions, 3 deletions
diff --git a/redfish-core/src/utils/json_utils.cpp b/redfish-core/src/utils/json_utils.cpp
index a47b4d8217..89723ccd12 100644
--- a/redfish-core/src/utils/json_utils.cpp
+++ b/redfish-core/src/utils/json_utils.cpp
@@ -15,6 +15,13 @@
*/
#include "utils/json_utils.hpp"
+#include "error_messages.hpp"
+#include "http/http_request.hpp"
+#include "http/http_response.hpp"
+#include "http/parsing.hpp"
+
+#include <nlohmann/json.hpp>
+
namespace redfish
{
@@ -24,14 +31,17 @@ namespace json_util
bool processJsonFromRequest(crow::Response& res, const crow::Request& req,
nlohmann::json& reqJson)
{
+ JsonParseResult ret = parseRequestAsJson(req, reqJson);
+ if (ret == JsonParseResult::BadContentType)
+ {
+ messages::unrecognizedRequestBody(res);
+ return false;
+ }
reqJson = nlohmann::json::parse(req.body, nullptr, false);
if (reqJson.is_discarded())
{
messages::malformedJSON(res);
-
- res.end();
-
return false;
}