summaryrefslogtreecommitdiff
path: root/redfish-core
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2022-08-08 02:42:51 +0300
committerEd Tanous <ed@tanous.net>2022-09-13 01:15:45 +0300
commit99351cd856038475cac146029e5db03767a1459c (patch)
treee7a493c416851de342a71f06fe0d71f3afae5c4b /redfish-core
parent3d36e3a514b0cfafcd00edc880b83d0eae87fed7 (diff)
downloadbmcweb-99351cd856038475cac146029e5db03767a1459c.tar.xz
Improve content type
We have a number of specialized content-type functions for varying levels of degree, and most of them rely on quite a few strings. This commit changes them to consolidate on two APIs. isContentTypeSupported, which as the name implies, takes a single content type, and returns a bool about whether or not that content type is allowed. getPreferedContentType, which takes an array of multiple options, and fine the first one in the list that matches the clients expected string. These two functions makes these functions more able to be reused in the future, and don't require specialized entries for each possible type or combination of types that we need to check for. Tested: Unit tests passing. Pretty good coverage. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I8b976d0cefec5f24e62fbbfae33d12cc803cb373
Diffstat (limited to 'redfish-core')
-rw-r--r--redfish-core/lib/log_services.hpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/redfish-core/lib/log_services.hpp b/redfish-core/lib/log_services.hpp
index 1b52d00f9a..2a26ab9e66 100644
--- a/redfish-core/lib/log_services.hpp
+++ b/redfish-core/lib/log_services.hpp
@@ -1673,7 +1673,9 @@ inline void requestRoutesDBusEventLogEntryDownload(App& app)
{
return;
}
- if (!http_helpers::isOctetAccepted(req.getHeaderValue("Accept")))
+ if (http_helpers::isContentTypeAllowed(
+ req.getHeaderValue("Accept"),
+ http_helpers::ContentType::OctetStream))
{
asyncResp->res.result(boost::beast::http::status::bad_request);
return;
@@ -3562,7 +3564,9 @@ inline void requestRoutesPostCodesEntryAdditionalData(App& app)
{
return;
}
- if (!http_helpers::isOctetAccepted(req.getHeaderValue("Accept")))
+ if (http_helpers::isContentTypeAllowed(
+ req.getHeaderValue("Accept"),
+ http_helpers::ContentType::OctetStream))
{
asyncResp->res.result(boost::beast::http::status::bad_request);
return;