summaryrefslogtreecommitdiff
path: root/include/http_utility.hpp
diff options
context:
space:
mode:
authorGunnar Mills <gmills@us.ibm.com>2022-02-03 00:56:44 +0300
committerGunnar Mills <gmills@us.ibm.com>2022-08-22 23:30:17 +0300
commita3526fee27da0e324cd022ea77d282d1146b3317 (patch)
treeb6fd58b0fee19a0afba75ed7aaea0fd58d856e0f /include/http_utility.hpp
parent0d4befa8f0b8c3fecb96f6c8c7acd26439ad122e (diff)
downloadbmcweb-a3526fee27da0e324cd022ea77d282d1146b3317.tar.xz
Remove q-factor weighting on Accept Header
bmcweb does not do anything with the q-factor weighting (;q=) so just remove it from the encoding. This is needed because routes like "/redfish/v1/Systems/system/LogServices/EventLog/Entries/<str>/attachment" have a check for isOctetAccepted. Even though */* is in the Accept Header isOctetAccepted still fails due to the q-factor weighting. On the system I tested, on firefox, Accept looks like: Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8 The GUI reported being unable to download a AdditionalDataURI (e.g. ...attachment/) Here is the GUI code attempting to download the additional data: https://github.com/openbmc/webui-vue/blob/9b79a6e7e3df3d3cbaf9a7750bbe343628022026/src/views/Logs/EventLogs/EventLogs.vue#L155 https://github.com/openbmc/webui-vue/blob/9b79a6e7e3df3d3cbaf9a7750bbe343628022026/src/locales/en-US.json#L251 Today this results in a 400 Bad Request due to isOctetAccepted. See: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept Tested: /redfish/v1/Systems/system/LogServices/PostCodes/Entries/<str>/attachment/ and .../EventLog/Entries/<str>/attachment now return correctly. Change-Id: I969f5f2c32c4acccd4d80615f17c44d0c8fabd0d Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
Diffstat (limited to 'include/http_utility.hpp')
-rw-r--r--include/http_utility.hpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/include/http_utility.hpp b/include/http_utility.hpp
index 46742a0ce6..b7844bacb8 100644
--- a/include/http_utility.hpp
+++ b/include/http_utility.hpp
@@ -47,8 +47,15 @@ inline bool requestPrefersHtml(std::string_view header)
inline bool isOctetAccepted(std::string_view header)
{
- for (const std::string& encoding : parseAccept(header))
+ for (std::string_view encoding : parseAccept(header))
{
+ // ignore any q-factor weighting (;q=)
+ std::size_t separator = encoding.find(";q=");
+
+ if (separator != std::string_view::npos)
+ {
+ encoding = encoding.substr(0, separator);
+ }
if (encoding == "*/*" || encoding == "application/octet-stream")
{
return true;