summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSunitha Harish <sunharis@in.ibm.com>2021-10-26 11:10:04 +0300
committerEd Tanous <ed@tanous.net>2021-11-18 20:33:46 +0300
commit7adb85ac3eafe6a0a63506e6d78d487581c69ded (patch)
tree2969e8c2582bc4e8450a6af2fdedf8f0d55eb4bc
parent308f70c77194b891c97e6f56c50adee4f39f0de7 (diff)
downloadbmcweb-7adb85ac3eafe6a0a63506e6d78d487581c69ded.tar.xz
EventService: Pass httpHeaders to subscriber
Custom http headers provided by the subscriber was not passed on to the http client request header This commit passes the http headers to the Subscriber constructor Tested by: Subscribe to events with custom headers Verify the event request packet sending the custom header to the subscriber Verified persistency of the subscription Signed-off-by: Sunitha Harish <sunharis@in.ibm.com> Change-Id: I9a4f59b6e9477fae96b380565885f4ac51e2a628
-rw-r--r--http/http_client.hpp6
-rw-r--r--redfish-core/include/event_service_manager.hpp15
2 files changed, 13 insertions, 8 deletions
diff --git a/http/http_client.hpp b/http/http_client.hpp
index f45449ba05..0c9e387280 100644
--- a/http/http_client.hpp
+++ b/http/http_client.hpp
@@ -197,8 +197,10 @@ class HttpClient : public std::enable_shared_from_this<HttpClient>
if ((respCode < 200) || (respCode >= 300))
{
// The listener failed to receive the Sent-Event
- BMCWEB_LOG_ERROR << "recvMessage() Listener Failed to "
- "receive Sent-Event";
+ BMCWEB_LOG_ERROR
+ << "recvMessage() Listener Failed to "
+ "receive Sent-Event. Header Response Code: "
+ << respCode;
self->state = ConnState::recvFailed;
self->handleConnState();
return;
diff --git a/redfish-core/include/event_service_manager.hpp b/redfish-core/include/event_service_manager.hpp
index b501265a17..010c991176 100644
--- a/redfish-core/include/event_service_manager.hpp
+++ b/redfish-core/include/event_service_manager.hpp
@@ -383,9 +383,7 @@ class Subscription : public persistent_data::UserSubscription
eventSeqNum(1),
host(inHost), port(inPort), path(inPath), uriProto(inUriProto)
{
- conn = std::make_shared<crow::HttpClient>(
- crow::connections::systemBus->get_io_context(), id, host, port,
- path, httpHeaders);
+ // Subscription constructor
}
Subscription(const std::shared_ptr<boost::beast::tcp_stream>& adaptor) :
@@ -398,12 +396,17 @@ class Subscription : public persistent_data::UserSubscription
void sendEvent(const std::string& msg)
{
- if (conn != nullptr)
+ if (conn == nullptr)
{
- conn->sendData(msg);
- this->eventSeqNum++;
+ // create the HttpClient connection
+ conn = std::make_shared<crow::HttpClient>(
+ crow::connections::systemBus->get_io_context(), id, host, port,
+ path, httpHeaders);
}
+ conn->sendData(msg);
+ eventSeqNum++;
+
if (sseConn != nullptr)
{
sseConn->sendData(eventSeqNum, msg);