diff options
author | Ed Tanous <edtanous@google.com> | 2021-09-09 05:57:44 +0300 |
---|---|---|
committer | Ed Tanous <ed@tanous.net> | 2021-10-19 18:50:40 +0300 |
commit | 4da044556a0f6ff36da707d48e46dd3246813d15 (patch) | |
tree | ce39635896aa132c9f88a947e44c9d21fa21bc3d | |
parent | bf888502a247d8374c70e7ceddc9862bf0ad88bd (diff) | |
download | bmcweb-4da044556a0f6ff36da707d48e46dd3246813d15.tar.xz |
Only generate headers once in EventService
This patchset builds on
https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/45761 and moves
the header generation into the constructor, rather than attempting to
repurpose addHeaders().
Tested:
Per Appu:
"Did basic check and its initialized to default as before."
Per Sunitha:
"Tested the basic event notification scenario with this commit. Works
fine"
https://gerrit.openbmc-project.xyz/c/openbmc/bmcweb/+/46703/2
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ia9e8b89574c7e0137f0d93f08378e45c2fcf5376
-rw-r--r-- | http/http_client.hpp | 26 | ||||
-rw-r--r-- | redfish-core/include/event_service_manager.hpp | 3 |
2 files changed, 9 insertions, 20 deletions
diff --git a/http/http_client.hpp b/http/http_client.hpp index 53040aeec7..cd6739843e 100644 --- a/http/http_client.hpp +++ b/http/http_client.hpp @@ -134,15 +134,6 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> { state = ConnState::sendInProgress; - BMCWEB_LOG_DEBUG << __FUNCTION__ << "(): " << host << ":" << port; - - req.version(static_cast<int>(11)); // HTTP 1.1 - req.target(uri); - req.method(boost::beast::http::verb::post); - - req.set(boost::beast::http::field::host, host); - req.keep_alive(true); - req.body() = data; req.prepare_payload(); @@ -390,13 +381,17 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> public: explicit HttpClient(boost::asio::io_context& ioc, const std::string& id, const std::string& destIP, const std::string& destPort, - const std::string& destUri) : + const std::string& destUri, + const boost::beast::http::fields& httpHeader) : conn(ioc), - timer(ioc), subId(id), host(destIP), port(destPort), uri(destUri), - retryCount(0), maxRetryAttempts(5), retryIntervalSecs(0), + timer(ioc), + req(boost::beast::http::verb::post, destUri, 11, "", httpHeader), + state(ConnState::initialized), subId(id), host(destIP), port(destPort), + uri(destUri), retryCount(0), maxRetryAttempts(5), retryIntervalSecs(0), retryPolicyAction("TerminateAfterRetries"), runningTimer(false) { - state = ConnState::initialized; + req.set(boost::beast::http::field::host, host); + req.keep_alive(true); } void sendData(const std::string& data) @@ -419,11 +414,6 @@ class HttpClient : public std::enable_shared_from_this<HttpClient> return; } - void setHeaders(const boost::beast::http::fields& httpHeaders) - { - req.base() = boost::beast::http::header<true>(httpHeaders); - } - void setRetryConfig(const uint32_t retryAttempts, const uint32_t retryTimeoutInterval) { diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp index 079b28abdc..b501265a17 100644 --- a/redfish-core/include/event_service_manager.hpp +++ b/redfish-core/include/event_service_manager.hpp @@ -385,7 +385,7 @@ class Subscription : public persistent_data::UserSubscription { conn = std::make_shared<crow::HttpClient>( crow::connections::systemBus->get_io_context(), id, host, port, - path); + path, httpHeaders); } Subscription(const std::shared_ptr<boost::beast::tcp_stream>& adaptor) : @@ -400,7 +400,6 @@ class Subscription : public persistent_data::UserSubscription { if (conn != nullptr) { - conn->setHeaders(httpHeaders); conn->sendData(msg); this->eventSeqNum++; } |