From adf60035e680e1a11fb128cbf9697114d1b9c6a9 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Wed, 31 Jul 2024 12:09:30 +0300 Subject: Suppress potential CONNECT response headers in curl's output (GH issue #407) --- bdep/http-service.cxx | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) 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 #include -#include // fdterm() +#include // fdterm() +#include #include @@ -15,6 +16,8 @@ namespace bdep { namespace http_service { + static optional 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 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 ())); -- cgit v1.1