git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 3/5] http: drop support for curl < 7.19.4

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jul 21, 2021, 22:22 UTC
Message-ID
<patch-3.5-faae88b7fec-20210721T220402Z-avarab@gmail.com>
In-Reply-To
<cover-0.5-00000000000-20210721T220402Z-avarab@gmail.com>
From: Jeff King <peff@peff.net>

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.4. 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>
---
 http.c | 50 --------------------------------------------------
 http.h |  4 ----
 2 files changed, 54 deletions(-)
diff --git a/http.c b/http.c
index ef00e930232..1f0d7664d35 100644
--- a/http.c
+++ b/http.c
@@ -28,9 +28,7 @@ static int min_curl_sessions = 1;
 static int curl_session_count;
 static int max_requests = -1;
 static CURLM *curlm;
-#ifndef NO_CURL_EASY_DUPHANDLE
 static CURL *curl_default;
-#endif
 
 #define PREV_BUF_SIZE 4096
 
@@ -440,24 +438,8 @@ static void init_curl_http_auth(CURL *result)
 
 	credential_fill(&http_auth);
 
-#if LIBCURL_VERSION_NUM >= 0x071301
 	curl_easy_setopt(result, CURLOPT_USERNAME, http_auth.username);
 	curl_easy_setopt(result, CURLOPT_PASSWORD, http_auth.password);
-#else
-	{
-		static struct strbuf up = STRBUF_INIT;
-		/*
-		 * Note that we assume we only ever have a single set of
-		 * credentials in a given program run, so we do not have
-		 * to worry about updating this buffer, only setting its
-		 * initial value.
-		 */
-		if (!up.len)
-			strbuf_addf(&up, "%s:%s",
-				http_auth.username, http_auth.password);
-		curl_easy_setopt(result, CURLOPT_USERPWD, up.buf);
-	}
-#endif
 }
 
 /* *var must be free-able */
@@ -471,22 +453,10 @@ static void var_override(const char **var, char *value)
 
 static void set_proxyauth_name_password(CURL *result)
 {
-#if LIBCURL_VERSION_NUM >= 0x071301
 		curl_easy_setopt(result, CURLOPT_PROXYUSERNAME,
 			proxy_auth.username);
 		curl_easy_setopt(result, CURLOPT_PROXYPASSWORD,
 			proxy_auth.password);
-#else
-		struct strbuf s = STRBUF_INIT;
-
-		strbuf_addstr_urlencode(&s, proxy_auth.username,
-					is_rfc3986_unreserved);
-		strbuf_addch(&s, ':');
-		strbuf_addstr_urlencode(&s, proxy_auth.password,
-					is_rfc3986_unreserved);
-		curl_proxyuserpwd = strbuf_detach(&s, NULL);
-		curl_easy_setopt(result, CURLOPT_PROXYUSERPWD, curl_proxyuserpwd);
-#endif
 }
 
 static void init_curl_proxy_auth(CURL *result)
@@ -748,7 +718,6 @@ void setup_curl_trace(CURL *handle)
 	curl_easy_setopt(handle, CURLOPT_DEBUGDATA, NULL);
 }
 
-#ifdef CURLPROTO_HTTP
 static long get_curl_allowed_protocols(int from_user)
 {
 	long allowed_protocols = 0;
@@ -764,7 +733,6 @@ static long get_curl_allowed_protocols(int from_user)
 
 	return allowed_protocols;
 }
-#endif
 
 #if LIBCURL_VERSION_NUM >=0x072f00
 static int get_curl_http_version_opt(const char *version_string, long *opt)
@@ -906,19 +874,11 @@ static CURL *get_curl_handle(void)
 	}
 
 	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
-#ifdef CURLPROTO_HTTP
 	curl_easy_setopt(result, CURLOPT_REDIR_PROTOCOLS,
 			 get_curl_allowed_protocols(0));
 	curl_easy_setopt(result, CURLOPT_PROTOCOLS,
 			 get_curl_allowed_protocols(-1));
-#else
-	warning(_("Protocol restrictions not supported with cURL < 7.19.4"));
-#endif
 	if (getenv("GIT_CURL_VERBOSE"))
 		http_trace_curl_no_data();
 	setup_curl_trace(result);
@@ -1012,11 +972,9 @@ static CURL *get_curl_handle(void)
 			die("Invalid proxy URL '%s'", curl_http_proxy);
 
 		curl_easy_setopt(result, CURLOPT_PROXY, proxy_auth.host);
-#if LIBCURL_VERSION_NUM >= 0x071304
 		var_override(&curl_no_proxy, getenv("NO_PROXY"));
 		var_override(&curl_no_proxy, getenv("no_proxy"));
 		curl_easy_setopt(result, CURLOPT_NOPROXY, curl_no_proxy);
-#endif
 	}
 	init_curl_proxy_auth(result);
 
@@ -1147,9 +1105,7 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
 			ssl_cert_password_required = 1;
 	}
 
-#ifndef NO_CURL_EASY_DUPHANDLE
 	curl_default = get_curl_handle();
-#endif
 }
 
 void http_cleanup(void)
@@ -1167,9 +1123,7 @@ void http_cleanup(void)
 	}
 	active_queue_head = NULL;
 
-#ifndef NO_CURL_EASY_DUPHANDLE
 	curl_easy_cleanup(curl_default);
-#endif
 
 	curl_multi_cleanup(curlm);
 	curl_global_cleanup();
@@ -1248,11 +1202,7 @@ struct active_request_slot *get_active_slot(void)
 	}
 
 	if (slot->curl == NULL) {
-#ifdef NO_CURL_EASY_DUPHANDLE
-		slot->curl = get_curl_handle();
-#else
 		slot->curl = curl_easy_duphandle(curl_default);
-#endif
 		curl_session_count++;
 	}
 
diff --git a/http.h b/http.h
index cb092622a73..19f19dbe74c 100644
--- a/http.h
+++ b/http.h
@@ -12,10 +12,6 @@
 
 #define DEFAULT_MAX_REQUESTS 5
 
-#if LIBCURL_VERSION_NUM == 0x071000
-#define NO_CURL_EASY_DUPHANDLE
-#endif
-
 /*
  * CURLOPT_USE_SSL was known as CURLOPT_FTP_SSL up to 7.16.4,
  * and the constants were known as CURLFTPSSL_*
-- 
2.32.0.874.ge7a9d58bfcf
Previous: Ævar Arnfjörð BjarmasonNext: Junio C Hamano
Message 42 of 162 in “dropping support for older curl”
  1. 0/4 dropping support for older curlJeff King, Aug 9, 2017
  2. 1/4 http: drop support for curl < 7.11.1Jeff King, Aug 9, 2017
  3. 2/4 http: drop support for curl < 7.16.0Jeff King, Aug 9, 2017
  4. Stefan BellerAug 9, 2017
  5. Jeff KingAug 9, 2017
  6. Junio C HamanoAug 9, 2017
  7. Nicolas Morey-ChaisemartinAug 9, 2017
  8. Jeff KingAug 9, 2017
  9. Nicolas Morey-ChaisemartinAug 9, 2017
  10. Jeff KingAug 9, 2017
  11. Jeff KingAug 9, 2017
  12. 3/4 http: drop support for curl < 7.19.4Jeff King, Aug 9, 2017
  13. Ævar Arnfjörð BjarmasonAug 9, 2017
  14. Jeff KingAug 9, 2017
  15. 5/4 curl: remove ifdef'd code never used with curl >=7.19.4Ævar Arnfjörð Bjarmason, Aug 9, 2017
  16. Stefan BellerAug 9, 2017
  17. Jeff KingAug 9, 2017
  18. Mischa POSLAWSKYAug 10, 2017
  19. Jeff KingAug 10, 2017
  20. 4/4 http: #error on too-old curlJeff King, Aug 9, 2017
  21. Stefan BellerAug 9, 2017
  22. Johannes SchindelinAug 9, 2017
  23. Jeff KingAug 9, 2017
  24. Johannes SchindelinAug 10, 2017
  25. Jeff KingAug 10, 2017
  26. Junio C HamanoAug 10, 2017
  27. Jeff KingAug 10, 2017
  28. Jeff KingAug 11, 2017
  29. Tom G. ChristensenAug 10, 2017
  30. Jeff KingAug 10, 2017
  31. Tom G. ChristensenAug 10, 2017
  32. Jeff KingAug 10, 2017
  33. Tom G. ChristensenAug 10, 2017
  34. Jeff KingAug 10, 2017
  35. Tom G. ChristensenAug 10, 2017
  36. Tom G. ChristensenAug 10, 2017
  37. Ævar Arnfjörð BjarmasonAug 9, 2017
  38. 0/5 drop support for ancient curlÆvar Arnfjörð Bjarmason, Jul 21, 2021
  39. 1/5 http: drop support for curl < 7.11.1Ævar Arnfjörð Bjarmason, Jul 21, 2021
  40. Junio C HamanoJul 21, 2021
  41. 2/5 http: drop support for curl < 7.16.0Ævar Arnfjörð Bjarmason, Jul 21, 2021
  42. 3/5 http: drop support for curl < 7.19.4Ævar Arnfjörð Bjarmason, Jul 21, 2021
  43. Junio C HamanoJul 21, 2021
  44. 4/5 http: drop support for curl < 7.19.3 and < 7.16.4 (again)Ævar Arnfjörð Bjarmason, Jul 21, 2021
  45. Junio C HamanoJul 21, 2021
  46. 5/5 http: rename CURLOPT_FILE to CURLOPT_WRITEDATAÆvar Arnfjörð Bjarmason, Jul 21, 2021
  47. Junio C HamanoJul 21, 2021
  48. Junio C HamanoJul 21, 2021
  49. brian m. carlsonJul 21, 2021
  50. Ævar Arnfjörð BjarmasonJul 22, 2021
  51. brian m. carlsonJul 22, 2021
  52. Ævar Arnfjörð BjarmasonJul 23, 2021
  53. Bagas SanjayaJul 22, 2021
  54. Jeff KingJul 23, 2021
  55. Junio C HamanoJul 23, 2021
  56. Randall S. BeckerJul 23, 2021
  57. Jeff KingJul 24, 2021
  58. 0/7 drop support for ancient curl, improve version checksÆvar Arnfjörð Bjarmason, Jul 30, 2021
  59. 1/7 http: drop support for curl < 7.11.1Ævar Arnfjörð Bjarmason, Jul 30, 2021
  60. 2/7 http: drop support for curl < 7.16.0Ævar Arnfjörð Bjarmason, Jul 30, 2021
  61. 3/7 http: drop support for curl < 7.19.4Ævar Arnfjörð Bjarmason, Jul 30, 2021
  62. 5/7 http: drop support for curl < 7.18.0 (again)Ævar Arnfjörð Bjarmason, Jul 30, 2021
  63. Junio C HamanoJul 30, 2021
  64. 4/7 http: drop support for curl < 7.19.3 and <= 7.16.4 (or <7.17.0) (again)Ævar Arnfjörð Bjarmason, Jul 30, 2021
  65. Junio C HamanoJul 30, 2021
  66. 6/7 http: rename CURLOPT_FILE to CURLOPT_WRITEDATAÆvar Arnfjörð Bjarmason, Jul 30, 2021
  67. 7/7 http: centralize the accounting of libcurl dependenciesÆvar Arnfjörð Bjarmason, Jul 30, 2021
  68. Junio C HamanoJul 30, 2021
  69. 0/5 drop support for ancient curlÆvar Arnfjörð Bjarmason, Jul 30, 2021
  70. 1/5 http: drop support for curl < 7.11.1Ævar Arnfjörð Bjarmason, Jul 30, 2021
  71. 2/5 http: drop support for curl < 7.16.0Ævar Arnfjörð Bjarmason, Jul 30, 2021
  72. Andrei RybakSep 10, 2021
  73. Jeff KingSep 11, 2021
  74. Junio C HamanoSep 11, 2021
  75. Jeff KingSep 11, 2021
  76. 3/5 http: drop support for curl < 7.19.4Ævar Arnfjörð Bjarmason, Jul 30, 2021
  77. 4/5 http: drop support for curl < 7.19.3 and < 7.17.0 (again)Ævar Arnfjörð Bjarmason, Jul 30, 2021
  78. 5/5 http: rename CURLOPT_FILE to CURLOPT_WRITEDATAÆvar Arnfjörð Bjarmason, Jul 30, 2021
  79. Junio C HamanoJul 30, 2021
  80. Junio C HamanoJul 30, 2021
  81. Junio C HamanoJul 30, 2021
  82. 0/5 post-v2.33 "drop support for ancient curl" follow-upÆvar Arnfjörð Bjarmason, Sep 8, 2021
  83. 1/5 http: drop support for curl < 7.18.0 (again)Ævar Arnfjörð Bjarmason, Sep 8, 2021
  84. Junio C HamanoSep 9, 2021
  85. 2/5 http: correct curl version check for CURLOPT_PINNEDPUBLICKEYÆvar Arnfjörð Bjarmason, Sep 8, 2021
  86. Jeff KingSep 8, 2021
  87. Junio C HamanoSep 9, 2021
  88. Jeff KingSep 10, 2021
  89. Jeff KingSep 10, 2021
  90. Ævar Arnfjörð BjarmasonSep 10, 2021
  91. Jeff KingSep 10, 2021
  92. Daniel StenbergSep 10, 2021
  93. Ævar Arnfjörð BjarmasonSep 10, 2021
  94. Daniel StenbergSep 10, 2021
  95. 3/5 http: correct version check for CURL_HTTP_VERSION_2_0Ævar Arnfjörð Bjarmason, Sep 8, 2021
  96. Jeff KingSep 8, 2021
  97. 4/5 http: centralize the accounting of libcurl dependenciesÆvar Arnfjörð Bjarmason, Sep 8, 2021
  98. Jeff KingSep 8, 2021
  99. Junio C HamanoSep 9, 2021
  100. Jeff KingSep 9, 2021
  101. 5/5 http: don't hardcode the value of CURL_SOCKOPT_OKÆvar Arnfjörð Bjarmason, Sep 8, 2021
  102. Junio C HamanoSep 9, 2021
  103. Junio C HamanoSep 9, 2021
  104. Jeff KingSep 8, 2021
  105. 0/8 post-v2.33 "drop support for ancient curl" follow-upÆvar Arnfjörð Bjarmason, Sep 10, 2021
  106. 1/8 INSTALL: don't mention the "curl" executable at allÆvar Arnfjörð Bjarmason, Sep 10, 2021
  107. Jeff KingSep 10, 2021
  108. 2/8 INSTALL: mention that we need libcurl 7.19.4 or newer to buildÆvar Arnfjörð Bjarmason, Sep 10, 2021
  109. Jeff KingSep 10, 2021
  110. Junio C HamanoSep 10, 2021
  111. Jeff KingSep 10, 2021
  112. 3/8 Makefile: drop support for curl < 7.9.8 (again)Ævar Arnfjörð Bjarmason, Sep 10, 2021
  113. Jeff KingSep 10, 2021
  114. 4/8 http: drop support for curl < 7.18.0 (again)Ævar Arnfjörð Bjarmason, Sep 10, 2021
  115. 5/8 http: correct version check for CURL_HTTP_VERSION_2Ævar Arnfjörð Bjarmason, Sep 10, 2021
  116. Jeff KingSep 10, 2021
  117. Daniel StenbergSep 10, 2021
  118. Jeff KingSep 10, 2021
  119. Ævar Arnfjörð BjarmasonSep 10, 2021
  120. 6/8 http: correct curl version check for CURLOPT_PINNEDPUBLICKEYÆvar Arnfjörð Bjarmason, Sep 10, 2021
  121. Junio C HamanoSep 10, 2021
  122. 7/8 http: centralize the accounting of libcurl dependenciesÆvar Arnfjörð Bjarmason, Sep 10, 2021
  123. Jeff KingSep 10, 2021
  124. 8/8 http: don't hardcode the value of CURL_SOCKOPT_OKÆvar Arnfjörð Bjarmason, Sep 10, 2021
  125. Jeff KingSep 10, 2021
  126. Jeff KingSep 10, 2021
  127. Ævar Arnfjörð BjarmasonSep 10, 2021
  128. Jeff KingSep 10, 2021
  129. Junio C HamanoSep 10, 2021
  130. Randall S. BeckerSep 10, 2021
  131. Ævar Arnfjörð BjarmasonSep 10, 2021
  132. Junio C HamanoSep 10, 2021
  133. Junio C HamanoSep 10, 2021
  134. Konstantin RyabitsevSep 10, 2021
  135. Junio C HamanoSep 10, 2021
  136. Ævar Arnfjörð BjarmasonSep 10, 2021
  137. 0/9 post-v2.33 "drop support for ancient curl" follow-upÆvar Arnfjörð Bjarmason, Sep 11, 2021
  138. 1/9 INSTALL: don't mention the "curl" executable at allÆvar Arnfjörð Bjarmason, Sep 11, 2021
  139. 2/9 INSTALL: reword and copy-edit the "libcurl" sectionÆvar Arnfjörð Bjarmason, Sep 11, 2021
  140. 3/9 INSTALL: mention that we need libcurl 7.19.4 or newer to buildÆvar Arnfjörð Bjarmason, Sep 11, 2021
  141. 4/9 Makefile: drop support for curl < 7.9.8 (again)Ævar Arnfjörð Bjarmason, Sep 11, 2021
  142. 5/9 http: drop support for curl < 7.18.0 (again)Ævar Arnfjörð Bjarmason, Sep 11, 2021
  143. 6/9 http: correct version check for CURL_HTTP_VERSION_2Ævar Arnfjörð Bjarmason, Sep 11, 2021
  144. 7/9 http: correct curl version check for CURLOPT_PINNEDPUBLICKEYÆvar Arnfjörð Bjarmason, Sep 11, 2021
  145. 8/9 http: centralize the accounting of libcurl dependenciesÆvar Arnfjörð Bjarmason, Sep 11, 2021
  146. 9/9 http: don't hardcode the value of CURL_SOCKOPT_OKÆvar Arnfjörð Bjarmason, Sep 11, 2021
  147. Jeff KingSep 11, 2021
  148. Junio C HamanoSep 12, 2021
  149. 0/9 post-v2.33 "drop support for ancient curl" follow-upÆvar Arnfjörð Bjarmason, Sep 13, 2021
  150. 1/9 INSTALL: don't mention the "curl" executable at allÆvar Arnfjörð Bjarmason, Sep 13, 2021
  151. 2/9 INSTALL: reword and copy-edit the "libcurl" sectionÆvar Arnfjörð Bjarmason, Sep 13, 2021
  152. 3/9 INSTALL: mention that we need libcurl 7.19.4 or newer to buildÆvar Arnfjörð Bjarmason, Sep 13, 2021
  153. 7/9 http: correct curl version check for CURLOPT_PINNEDPUBLICKEYÆvar Arnfjörð Bjarmason, Sep 13, 2021
  154. 6/9 http: correct version check for CURL_HTTP_VERSION_2Ævar Arnfjörð Bjarmason, Sep 13, 2021
  155. 4/9 Makefile: drop support for curl < 7.9.8 (again)Ævar Arnfjörð Bjarmason, Sep 13, 2021
  156. 5/9 http: drop support for curl < 7.18.0 (again)Ævar Arnfjörð Bjarmason, Sep 13, 2021
  157. 8/9 http: centralize the accounting of libcurl dependenciesÆvar Arnfjörð Bjarmason, Sep 13, 2021
  158. 9/9 http: don't hardcode the value of CURL_SOCKOPT_OKÆvar Arnfjörð Bjarmason, Sep 13, 2021
  159. Jeff KingSep 13, 2021
  160. Junio C HamanoSep 13, 2021
  161. Tom G. ChristensenAug 10, 2017
  162. Johannes SchindelinAug 14, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.