Skip to content

Commit

Permalink
feat(outputs_http): implement keep alive
Browse files Browse the repository at this point in the history
Signed-off-by: Samuel Gaist <[email protected]>
  • Loading branch information
sgaist authored and poiana committed Dec 18, 2023
1 parent 691bc8b commit d99c137
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions falco.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ http_output:
# Whether to echo server answers to stdout
echo: false
compress_uploads: false
keep_alive: false

# [Stable] `program_output`
#
Expand Down
4 changes: 4 additions & 0 deletions userspace/falco/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,10 @@ void falco_configuration::load_yaml(const std::string& config_name, const yaml_h
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
5 changes: 5 additions & 0 deletions userspace/falco/outputs_http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ bool falco::outputs::output_http::init(const config& oc, bool buffered, const st
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

0 comments on commit d99c137

Please sign in to comment.