diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2024-07-31 12:38:16 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2024-07-31 14:34:22 +0300 |
commit | 4e56d4623cc538618b72af01c8da9ad33215cdb2 (patch) | |
tree | c2dca254ac2b70420ebabfbdfe197e48e7a67ad4 | |
parent | 3f4cdc9ad159621446579c5385bb4582217c4ddf (diff) |
Suppress potential CONNECT response headers in curl's output (GH issue #407)
-rw-r--r-- | bbot/agent/http-service.cxx | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/bbot/agent/http-service.cxx b/bbot/agent/http-service.cxx index 1921edc..3214885 100644 --- a/bbot/agent/http-service.cxx +++ b/bbot/agent/http-service.cxx @@ -4,6 +4,7 @@ #include <bbot/agent/http-service.hxx> #include <libbutl/curl.hxx> +#include <libbutl/semantic-version.hxx> #include <bbot/diagnostics.hxx> @@ -14,6 +15,8 @@ namespace bbot { namespace http_service { + static optional<semantic_version> curl_version; + result post (const agent_options& o, const string& u, const parameters& params) { @@ -77,6 +80,17 @@ namespace bbot p.name + '=' + p.value); } + // Query the curl's version, if not done yet. If something goes wrong, + // set the version to 0.0.0 so that we treat it as a really old curl. + // + if (!curl_version) + { + if (optional<semantic_version> v = curl::version (path ("curl"))) + curl_version = move (*v); + else + curl_version = semantic_version {0, 0, 0}; + } + // Note that we prefer the low-level process API for running curl over // using butl::curl because in this context it is restrictive and // inconvenient. @@ -110,6 +124,23 @@ namespace bbot // "--include", + // Note that in the presence of the + // --include|-i option, the output may + // include the CONNECT request response + // headers if curl tunnels through a + // proxy. To suppress these headers we + // also add the + // --suppress-connect-headers option for + // the curl versions 7.54.0 (when the + // option was invented) and above. For + // the earlier versions we just don't + // support the tunneling. + // + (*curl_version >= + semantic_version {7, 54, 0} + ? "--suppress-connect-headers" + : nullptr), + "--max-time", o.request_timeout (), "--connect-timeout", o.connect_timeout (), fos, |