Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update(config): Improve http output, add compression and keep_alive #2974

Merged
merged 2 commits into from Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions falco.yaml
Expand Up @@ -566,6 +566,8 @@ http_output:
client_key: "/etc/ssl/certs/client.key"
# Whether to echo server answers to stdout
echo: false
compress_uploads: false
keep_alive: false

# [Stable] `program_output`
#
Expand Down
8 changes: 8 additions & 0 deletions userspace/falco/configuration.cpp
Expand Up @@ -309,6 +309,14 @@ void falco_configuration::load_yaml(const std::string& config_name, const yaml_h
client_key = config.get_scalar<std::string>("http_output.client_key", "/etc/ssl/certs/client.key");
http_output.options["client_key"] = client_key;

bool compress_uploads;
compress_uploads = config.get_scalar<bool>("http_output.compress_uploads", false);
http_output.options["compress_uploads"] = compress_uploads? std::string("true") : std::string("false");

bool keep_alive;
keep_alive = config.get_scalar<bool>("http_output.keep_alive", false);
http_output.options["keep_alive"] = keep_alive? std::string("true") : std::string("false");

m_outputs.push_back(http_output);
}

Expand Down
10 changes: 10 additions & 0 deletions userspace/falco/outputs_http.cpp
Expand Up @@ -97,6 +97,16 @@ bool falco::outputs::output_http::init(const config& oc, bool buffered, const st
CHECK_RES(curl_easy_setopt(m_curl, CURLOPT_WRITEFUNCTION, noop_write_callback));
}

if(m_oc.options["compress_uploads"] == std::string("true"))
{
CHECK_RES(curl_easy_setopt(m_curl, CURLOPT_TRANSFER_ENCODING, 1L));
}

if(m_oc.options["keep_alive"] == std::string("true"))
{
CHECK_RES(curl_easy_setopt(m_curl, CURLOPT_TCP_KEEPALIVE, 1L));
}

if(res != CURLE_OK)
{
err = "libcurl error: " + std::string(curl_easy_strerror(res));
Expand Down