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
diff --git a/http/http_client.hpp b/http/http_client.hpp
index 53040ae..cd67398 100644
--- a/http/http_client.hpp
+++ b/http/http_client.hpp
@@ -134,15 +134,6 @@
{
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 @@
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 @@
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)
{