Add content type to HTTP events
Some receiving servers require that content-type be sent. The Redfish
specification does not clarify whether or not content-type should be
specified, but the HTTP RFC makees it clear, as does security
guidelines.
Tested: Set up Redfish-Event-Listener and modify to print headers.
Observe that application/json header is now set when events are
submitted to the server.
Change-Id: Idc96848e04f185743b14bd345d46418d38f5f5b1
Signed-off-by: Ed Tanous <etanous@nvidia.com>
diff --git a/redfish-core/src/subscription.cpp b/redfish-core/src/subscription.cpp
index 34dc76f..00c9036 100644
--- a/redfish-core/src/subscription.cpp
+++ b/redfish-core/src/subscription.cpp
@@ -33,6 +33,8 @@
#include <boost/asio/error.hpp>
#include <boost/asio/io_context.hpp>
#include <boost/asio/steady_timer.hpp>
+#include <boost/beast/http/field.hpp>
+#include <boost/beast/http/fields.hpp>
#include <boost/beast/http/verb.hpp>
#include <boost/system/errc.hpp>
#include <boost/url/format.hpp>
@@ -191,11 +193,14 @@
if (client)
{
+ boost::beast::http::fields httpHeadersCopy(userSub->httpHeaders);
+ httpHeadersCopy.set(boost::beast::http::field::content_type,
+ "application/json");
client->sendDataWithCallback(
std::move(msg), userSub->destinationUrl,
static_cast<ensuressl::VerifyCertificate>(
userSub->verifyCertificate),
- userSub->httpHeaders, boost::beast::http::verb::post,
+ httpHeadersCopy, boost::beast::http::verb::post,
std::bind_front(&Subscription::resHandler, this,
shared_from_this()));
return true;