diff --git a/userspace/falco/falco_outputs.cpp b/userspace/falco/falco_outputs.cpp index 4a467fc8..ed38669e 100644 --- a/userspace/falco/falco_outputs.cpp +++ b/userspace/falco/falco_outputs.cpp @@ -135,7 +135,7 @@ void falco_outputs::add_output(falco::outputs::config oc) throw falco_exception("Output not supported: " + oc.name); } - oo->init(oc, m_buffered, m_hostname); + oo->init(oc, m_buffered, m_hostname, m_json_output); m_outputs.push_back(oo); } diff --git a/userspace/falco/outputs.h b/userspace/falco/outputs.h index 937d1ae0..6b8e456e 100644 --- a/userspace/falco/outputs.h +++ b/userspace/falco/outputs.h @@ -63,11 +63,12 @@ class abstract_output public: virtual ~abstract_output() {} - void init(config oc, bool buffered, std::string hostname) + void init(config oc, bool buffered, std::string hostname, bool json_output) { m_oc = oc; m_buffered = buffered; m_hostname = hostname; + m_json_output = json_output; } // Return the output's name as per its configuration. @@ -89,6 +90,7 @@ protected: config m_oc; bool m_buffered; std::string m_hostname; + bool m_json_output; }; } // namespace outputs diff --git a/userspace/falco/outputs_http.cpp b/userspace/falco/outputs_http.cpp index 5a2b30f1..c9c5b851 100644 --- a/userspace/falco/outputs_http.cpp +++ b/userspace/falco/outputs_http.cpp @@ -28,7 +28,12 @@ void falco::outputs::output_http::output(const message *msg) curl = curl_easy_init(); if(curl) { - slist1 = curl_slist_append(slist1, "Content-Type: application/json"); + if (m_json_output) + { + slist1 = curl_slist_append(slist1, "Content-Type: application/json"); + } else { + slist1 = curl_slist_append(slist1, "Content-Type: text/plain"); + } curl_easy_setopt(curl, CURLOPT_HTTPHEADER, slist1); curl_easy_setopt(curl, CURLOPT_URL, m_oc.options["url"].c_str()); curl_easy_setopt(curl, CURLOPT_POSTFIELDS, msg->msg.c_str());