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
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp
index 9e958cb..fc347dc 100644
--- a/redfish-core/lib/certificate_service.hpp
+++ b/redfish-core/lib/certificate_service.hpp
@@ -1,8 +1,10 @@
#pragma once
#include <app.hpp>
+#include <async_resp.hpp>
#include <boost/system/linux_error.hpp>
#include <dbus_utility.hpp>
+#include <http_response.hpp>
#include <query.hpp>
#include <registries/privilege_registry.hpp>
@@ -702,7 +704,8 @@
}
}
asyncResp->res.addHeader(
- "Location", std::string_view(certURL.data(), certURL.size()));
+ boost::beast::http::field::location,
+ std::string_view(certURL.data(), certURL.size()));
},
service, objectPath, certs::dbusPropIntf, "GetAll",
certs::certPropIntf);