diff options
| author | Junio C Hamano <gitster@pobox.com> | 2015-09-28 14:46:05 -0700 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2015-09-28 14:46:05 -0700 |
| commit | f2df3104ce45bc1ee6d7c16f3a02f1d157c65e07 (patch) | |
| tree | 0fab49f2d65cee265a23f3b95e84c57a0e38430f /http.c | |
| parent | df37727a65c87cf9bba35befca1255031649553f (diff) | |
| parent | b258116462399b318c86165c61a5c7123043cfd4 (diff) | |
| download | git-f2df3104ce45bc1ee6d7c16f3a02f1d157c65e07.tar.gz | |
Merge branch 'jk/transfer-limit-redirection' into maint-2.3
Diffstat (limited to 'http.c')
| -rw-r--r-- | http.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -8,6 +8,7 @@ #include "credential.h" #include "version.h" #include "pkt-line.h" +#include "transport.h" int active_requests; int http_is_verbose; @@ -303,6 +304,7 @@ static void set_curl_keepalive(CURL *c) static CURL *get_curl_handle(void) { CURL *result = curl_easy_init(); + long allowed_protocols = 0; if (!result) die("curl_easy_init failed"); @@ -350,11 +352,27 @@ static CURL *get_curl_handle(void) } curl_easy_setopt(result, CURLOPT_FOLLOWLOCATION, 1); + curl_easy_setopt(result, CURLOPT_MAXREDIRS, 20); #if LIBCURL_VERSION_NUM >= 0x071301 curl_easy_setopt(result, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL); #elif LIBCURL_VERSION_NUM >= 0x071101 curl_easy_setopt(result, CURLOPT_POST301, 1); #endif +#if LIBCURL_VERSION_NUM >= 0x071304 + if (is_transport_allowed("http")) + allowed_protocols |= CURLPROTO_HTTP; + if (is_transport_allowed("https")) + allowed_protocols |= CURLPROTO_HTTPS; + if (is_transport_allowed("ftp")) + allowed_protocols |= CURLPROTO_FTP; + if (is_transport_allowed("ftps")) + allowed_protocols |= CURLPROTO_FTPS; + curl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS, allowed_protocols); +#else + if (transport_restrict_protocols()) + warning("protocol restrictions not applied to curl redirects because\n" + "your curl version is too old (>= 7.19.4)"); +#endif if (getenv("GIT_CURL_VERBOSE")) curl_easy_setopt(result, CURLOPT_VERBOSE, 1); |
