diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2024-07-31 12:09:30 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2024-07-31 14:32:22 +0300 |
commit | adf60035e680e1a11fb128cbf9697114d1b9c6a9 (patch) | |
tree | b8896cc0dc9326a786960c8cb25c437364a8534d | |
parent | 10dee0974d2bc0c9e41f293273e94fb8c7727620 (diff) |
Suppress potential CONNECT response headers in curl's output (GH issue #407)
-rw-r--r-- | bdep/http-service.cxx | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/bdep/http-service.cxx b/bdep/http-service.cxx index 63e1e59..dc04bd9 100644 --- a/bdep/http-service.cxx +++ b/bdep/http-service.cxx @@ -4,7 +4,8 @@ #include <bdep/http-service.hxx> #include <libbutl/curl.hxx> -#include <libbutl/fdstream.hxx> // fdterm() +#include <libbutl/fdstream.hxx> // fdterm() +#include <libbutl/semantic-version.hxx> #include <bdep/diagnostics.hxx> @@ -15,6 +16,8 @@ namespace bdep { namespace http_service { + static optional<semantic_version> curl_version; + result post (const common_options& o, const url& u, const parameters& params) { @@ -112,6 +115,17 @@ namespace bdep 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 (o.curl ())) + curl_version = move (*v); + else + curl_version = semantic_version {0, 0, 0}; + } + // Note that it's a bad idea to issue the diagnostics while curl is // running, as it will be messed up with the progress output. Thus, we // throw the runtime_error exception on the HTTP response parsing error @@ -148,6 +162,18 @@ namespace bdep // "--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), + fos, u.string ())); |