aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bbot/agent/http-service.cxx31
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,