http: drop support for curl < 7.19.4

In the last commit we dropped support for curl < 7.16.0, let's continue that and drop support for versions older than 7.19.3. This allows us to simplify the code by getting rid of some "#ifdef"'s. Git was broken with vanilla curl < 7.19.4 from v2.12.0 until v2.15.0. Compiling with it was broken by using CURLPROTO_* outside any "#ifdef" in aeae4db174 (http: create function to get curl allowed protocols, 2016-12-14), and fixed in v2.15.0 in f18777ba6ef (http: fix handling of missing CURLPROTO_*, 2017-08-11). It's unclear how much anyone was impacted by that in practice, since as noted in [1] RHEL versions using curl older than that still compiled, because RedHat backported some features. Perhaps other vendors did the same. Still, it's one datapoint indicating that it wasn't in active use at the time. That (the v2.12.0 release) was in Feb 24, 2017, with v2.15.0 on Oct 30, 2017, it's now mid-2021. 1. http://lore.kernel.org/git/c8a2716d-76ac-735c-57f9-175ca3acbcb0@jupiterrise.com; followed-up by f18777ba6ef (http: fix handling of missing CURLPROTO_*, 2017-08-11) Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Jul 30, 2021 at 19:59 UTC 644de29e220de7441e51a29bf512278b3de0bbe1
2 files changed -54
http.c
-50
@@ -28,9 +28,7 @@ static int min_curl_sessions = 1;
28 static int curl_session_count;
29 static int max_requests = -1;
30 static CURLM *curlm;
31 -#ifndef NO_CURL_EASY_DUPHANDLE
31 static CURL *curl_default;
33 -#endif
32
33 #define PREV_BUF_SIZE 4096
34
@@ -440,24 +438,8 @@ static void init_curl_http_auth(CURL *result)
438
439 credential_fill(&http_auth);
440
443 -#if LIBCURL_VERSION_NUM >= 0x071301
441 curl_easy_setopt(result, CURLOPT_USERNAME, http_auth.username);
442 curl_easy_setopt(result, CURLOPT_PASSWORD, http_auth.password);
446 -#else
447 - {
448 - static struct strbuf up = STRBUF_INIT;
449 - /*
450 - * Note that we assume we only ever have a single set of
451 - * credentials in a given program run, so we do not have
452 - * to worry about updating this buffer, only setting its
453 - * initial value.
454 - */
455 - if (!up.len)
456 - strbuf_addf(&up, "%s:%s",
457 - http_auth.username, http_auth.password);
458 - curl_easy_setopt(result, CURLOPT_USERPWD, up.buf);
459 - }
460 -#endif
443 }
444
445 /* *var must be free-able */
@@ -471,22 +453,10 @@ static void var_override(const char **var, char *value)
453
454 static void set_proxyauth_name_password(CURL *result)
455 {
474 -#if LIBCURL_VERSION_NUM >= 0x071301
456 curl_easy_setopt(result, CURLOPT_PROXYUSERNAME,
457 proxy_auth.username);
458 curl_easy_setopt(result, CURLOPT_PROXYPASSWORD,
459 proxy_auth.password);
479 -#else
480 - struct strbuf s = STRBUF_INIT;
481 -
482 - strbuf_addstr_urlencode(&s, proxy_auth.username,
483 - is_rfc3986_unreserved);
484 - strbuf_addch(&s, ':');
485 - strbuf_addstr_urlencode(&s, proxy_auth.password,
486 - is_rfc3986_unreserved);
487 - curl_proxyuserpwd = strbuf_detach(&s, NULL);
488 - curl_easy_setopt(result, CURLOPT_PROXYUSERPWD, curl_proxyuserpwd);
489 -#endif
460 }
461
462 static void init_curl_proxy_auth(CURL *result)
@@ -748,7 +718,6 @@ void setup_curl_trace(CURL *handle)
718 curl_easy_setopt(handle, CURLOPT_DEBUGDATA, NULL);
719 }
720
751 -#ifdef CURLPROTO_HTTP
721 static long get_curl_allowed_protocols(int from_user)
722 {
723 long allowed_protocols = 0;
@@ -764,7 +733,6 @@ static long get_curl_allowed_protocols(int from_user)
733
734 return allowed_protocols;
735 }
767 -#endif
736
737 #if LIBCURL_VERSION_NUM >=0x072f00
738 static int get_curl_http_version_opt(const char *version_string, long *opt)
@@ -906,19 +874,11 @@ static CURL *get_curl_handle(void)
874 }
875
876 curl_easy_setopt(result, CURLOPT_MAXREDIRS, 20);
909 -#if LIBCURL_VERSION_NUM >= 0x071301
877 curl_easy_setopt(result, CURLOPT_POSTREDIR, CURL_REDIR_POST_ALL);
911 -#elif LIBCURL_VERSION_NUM >= 0x071101
912 - curl_easy_setopt(result, CURLOPT_POST301, 1);
913 -#endif
914 -#ifdef CURLPROTO_HTTP
878 curl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS,
879 get_curl_allowed_protocols(0));
880 curl_easy_setopt(result, CURLOPT_PROTOCOLS,
881 get_curl_allowed_protocols(-1));
919 -#else
920 - warning(_("Protocol restrictions not supported with cURL < 7.19.4"));
921 -#endif
882 if (getenv("GIT_CURL_VERBOSE"))
883 http_trace_curl_no_data();
884 setup_curl_trace(result);
@@ -1012,11 +972,9 @@ static CURL *get_curl_handle(void)
972 die("Invalid proxy URL '%s'", curl_http_proxy);
973
974 curl_easy_setopt(result, CURLOPT_PROXY, proxy_auth.host);
1015 -#if LIBCURL_VERSION_NUM >= 0x071304
975 var_override(&curl_no_proxy, getenv("NO_PROXY"));
976 var_override(&curl_no_proxy, getenv("no_proxy"));
977 curl_easy_setopt(result, CURLOPT_NOPROXY, curl_no_proxy);
1019 -#endif
978 }
979 init_curl_proxy_auth(result);
980
@@ -1147,9 +1105,7 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
1105 ssl_cert_password_required = 1;
1106 }
1107
1150 -#ifndef NO_CURL_EASY_DUPHANDLE
1108 curl_default = get_curl_handle();
1152 -#endif
1109 }
1110
1111 void http_cleanup(void)
@@ -1167,9 +1123,7 @@ void http_cleanup(void)
1123 }
1124 active_queue_head = NULL;
1125
1170 -#ifndef NO_CURL_EASY_DUPHANDLE
1126 curl_easy_cleanup(curl_default);
1172 -#endif
1127
1128 curl_multi_cleanup(curlm);
1129 curl_global_cleanup();
@@ -1248,11 +1202,7 @@ struct active_request_slot *get_active_slot(void)
1202 }
1203
1204 if (slot->curl == NULL) {
1251 -#ifdef NO_CURL_EASY_DUPHANDLE
1252 - slot->curl = get_curl_handle();
1253 -#else
1205 slot->curl = curl_easy_duphandle(curl_default);
1255 -#endif
1206 curl_session_count++;
1207 }
1208
http.h
-4
@@ -12,10 +12,6 @@
12
13 #define DEFAULT_MAX_REQUESTS 5
14
15 -#if LIBCURL_VERSION_NUM == 0x071000
16 -#define NO_CURL_EASY_DUPHANDLE
17 -#endif
18 -
15 /*
16 * CURLOPT_USE_SSL was known as CURLOPT_FTP_SSL up to 7.16.4,
17 * and the constants were known as CURLFTPSSL_*