mirror of
https://github.com/falcosecurity/falco.git
synced 2025-07-10 05:03:37 +00:00
fix(userspace/engine,userspace/falco): set http output contenttype to text/plain when json output is disabled
Signed-off-by: Federico Di Pierro <nierro92@gmail.com> Co-authored-by: Leonardo Grasso <me@leonardograsso.com>
This commit is contained in:
parent
eaccfbe82d
commit
475ed0dbeb
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user