summaryrefslogtreecommitdiff
path: root/http/http_connection.hpp
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2022-09-13 22:11:19 +0300
committerEd Tanous <edtanous@google.com>2022-09-13 22:22:32 +0300
commit06fe2750bcacbe0a12f91ba5eaf1780fde60e028 (patch)
treefb143dc4fed74330487b6813559b56175b433176 /http/http_connection.hpp
parent99351cd856038475cac146029e5db03767a1459c (diff)
downloadbmcweb-06fe2750bcacbe0a12f91ba5eaf1780fde60e028.tar.xz
Make Accepts: */* default to JSON
There are apparently libraries that use an Accepts header of */*, instead of simply omitting the Accepts header, or providing a more correct value for that header. 99351cd856038475cac146029e5db03767a1459c Improve content type The above commit attempted to refine our handling of this header, and changed the behavior for */* to default to HTML. While this is arguably "correct" to the HTTP RFC, and the clients that do this are definitely wrong in their implementation, we can try to shield them a little from their incorrectness, and we can certainly avoid compatibility issues with these clients, without effecting the clients that implement the spec correctly. This commit changes the priority order of Accepts header to JSON then HTML, instead of the other way around. Tested: curl --insecure -H "Accept: */*" --user root:0penBmc \ https://192.168.7.2/redfish/v1 Now returns a json payload. Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I7850a3afb0b5d635f8d632fb0a9f790e53fe4466
Diffstat (limited to 'http/http_connection.hpp')
-rw-r--r--http/http_connection.hpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/http/http_connection.hpp b/http/http_connection.hpp
index 376eeec73d..025c1430ef 100644
--- a/http/http_connection.hpp
+++ b/http/http_connection.hpp
@@ -455,8 +455,8 @@ class Connection :
if (res.body().empty() && !res.jsonValue.empty())
{
using http_helpers::ContentType;
- std::array<ContentType, 2> allowed{ContentType::HTML,
- ContentType::JSON};
+ std::array<ContentType, 2> allowed{ContentType::JSON,
+ ContentType::HTML};
ContentType prefered =
getPreferedContentType(req->getHeaderValue("Accept"), allowed);