summaryrefslogtreecommitdiff
path: root/redfish-core/include/event_service_manager.hpp
diff options
context:
space:
mode:
authorEd Tanous <edtanous@google.com>2021-09-09 02:40:12 +0300
committerEd Tanous <ed@tanous.net>2021-10-17 23:53:48 +0300
commit601c71aef4ac54e28933bc6e022c7e1f6e8bf1e8 (patch)
tree7935403a56beb6a85749a22e338812c3f0ac9b24 /redfish-core/include/event_service_manager.hpp
parent565c0911faea72128a3a8c4b8b5ec3094756d82e (diff)
downloadbmcweb-601c71aef4ac54e28933bc6e022c7e1f6e8bf1e8.tar.xz
Improve HttpHeaders in EventService
This commit moves the internal data structures to use boost::beast::http::fields as its internal data structure. fields is a hyper-optimized map implementation for http headers, and has a lot of nice escaping properties. It is what boost::beast::http::request uses under the covers, so this has some niceties in reducing the amount of code, and means we can completely remove the headers structure, and simply rely on req. When this conversion was done, now the type safety of the incoming data needs to have better checking, as loading into the keys has new requirements (like values must be strings), so that type conversion code for to and from json was added, and the POST and PATCH handler updated to put into the new structure. Tested: curl -vvvv --insecure -u root:0penBmc "https://192.168.7.2:443/redfish/v1/EventService/Subscriptions" -X POST -d "{\"Destination\":\"http://192.168.7.2:443/\",\"Context\":\"Public\",\"Protocol\":\"Redfish\",\"HttpHeaders\":[{\"Foo\":\"Bar\"}]}" returned 200. Tested various "bad" headers, and observed the correct type errors. Issued: systemctl restart bmcweb. Subscription restored properly verified with. GET https://localhost:8001/redfish/v1/EventService/Subscriptions/183211400 Signed-off-by: Ed Tanous <edtanous@google.com> Change-Id: I331f65e1a3960f1812c9baac27dbdcb1d54f112c
Diffstat (limited to 'redfish-core/include/event_service_manager.hpp')
-rw-r--r--redfish-core/include/event_service_manager.hpp12
1 files changed, 1 insertions, 11 deletions
diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp
index 3f398d78b1..079b28abdc 100644
--- a/redfish-core/include/event_service_manager.hpp
+++ b/redfish-core/include/event_service_manager.hpp
@@ -400,17 +400,7 @@ class Subscription : public persistent_data::UserSubscription
{
if (conn != nullptr)
{
- std::vector<std::pair<std::string, std::string>> reqHeaders;
- for (const auto& header : httpHeaders)
- {
- for (const auto& item : header.items())
- {
- std::string key = item.key();
- std::string val = item.value();
- reqHeaders.emplace_back(std::pair(key, val));
- }
- }
- conn->setHeaders(reqHeaders);
+ conn->setHeaders(httpHeaders);
conn->sendData(msg);
this->eventSeqNum++;
}