diff options
author | Ed Tanous <edtanous@google.com> | 2022-03-17 19:12:17 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2022-08-06 20:30:15 +0300 |
commit | d9f6c621036162e9071ce3c3a333b4544c6db870 (patch) | |
tree | d398d7e98cad67243f5d54ecefc1f787a47306a3 /include/openbmc_dbus_rest.hpp | |
parent | 5907571df69a5e1a6f3e0633ad42f2dc7fa6ba25 (diff) | |
download | bmcweb-d9f6c621036162e9071ce3c3a333b4544c6db870.tar.xz |
Use enum overload for field setting
There are two overloads of addHeader, one that takes a string, and one
that takes a boost enum. For most common headers, boost contains a
string table with all of those entries anyway, so there's no point in
duplicating the strings, and ensures that we don't make trivial
mistakes, like capitalization or - versus underscore that aren't caught
at compile time.
Tested:
This saves a trivial amount (572 bytes) of compressed binary size.
curl --insecure -vvv --user root:0penBmc https://192.168.7.2/redfish/v1
returns < Content-Type: application/json
curl --insecure -vvv -H "Accept: text/html" --user root:0penBmc https://192.168.7.2/redfish/v1
Returns
< Content-Type: text/html;charset=UTF-8
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: I34c198b4f9e219247fcfe719f9b3616d35aea3dc
Diffstat (limited to 'include/openbmc_dbus_rest.hpp')
-rw-r--r-- | include/openbmc_dbus_rest.hpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp index 9c8d9f5e71..f458fac10d 100644 --- a/include/openbmc_dbus_rest.hpp +++ b/include/openbmc_dbus_rest.hpp @@ -2547,7 +2547,7 @@ inline void requestRoutes(App& app) continue; } - asyncResp->res.addHeader("Content-Type", + asyncResp->res.addHeader(boost::beast::http::field::content_type, "application/octet-stream"); // Assuming only one dump file will be present in the dump @@ -2567,8 +2567,9 @@ inline void requestRoutes(App& app) std::string contentDispositionParam = "attachment; filename=\"" + dumpFileName + "\""; - asyncResp->res.addHeader("Content-Disposition", - contentDispositionParam); + asyncResp->res.addHeader( + boost::beast::http::field::content_disposition, + contentDispositionParam); asyncResp->res.body() = {std::istreambuf_iterator<char>(readFile), std::istreambuf_iterator<char>()}; |