summaryrefslogtreecommitdiff
path: root/http.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-09-28 19:16:54 -0700
committerJunio C Hamano <gitster@pobox.com>2015-09-28 19:16:54 -0700
commit3adc4ec7b9e1d2118501728a75a5b93d971974fa (patch)
tree807d65746060e9967d6d016b230730ef5fd24334 /http.c
parentbe08dee9738eaaa0423885ed189c2b6ad8368cf0 (diff)
parent24358560c3c0ab51c9ef8178d99f46711716f6c0 (diff)
downloadgit-3adc4ec7b9e1d2118501728a75a5b93d971974fa.tar.gz
Sync with v2.5.4
Diffstat (limited to 'http.c')
-rw-r--r--http.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/http.c b/http.c
index 9dce38025c..0f924a8b48 100644
--- a/http.c
+++ b/http.c
@@ -9,6 +9,7 @@
#include "version.h"
#include "pkt-line.h"
#include "gettext.h"
+#include "transport.h"
int active_requests;
int http_is_verbose;
@@ -356,6 +357,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");
@@ -425,11 +427,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);