diff mbox series

[1/2] Conditional use of CURLOPT_PROXYHEADER based on libcurl version

Message ID 20241014131346.3556163-2-asedeno@mit.edu (mailing list archive)
State New
Headers show
Series Restore support for older libcurl and fix some typos | expand

Commit Message

Alejandro R. Sedeño Oct. 14, 2024, 1:13 p.m. UTC
Signed-off-by: Alejandro R. Sedeño <asedeno@mit.edu>
Signed-off-by: Alejandro R. Sedeño <asedeno@google.com>
---
 git-curl-compat.h | 7 +++++++
 http.c            | 4 ++++
 2 files changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/git-curl-compat.h b/git-curl-compat.h
index e1d0bdd273..08ae73e0f1 100644
--- a/git-curl-compat.h
+++ b/git-curl-compat.h
@@ -65,6 +65,13 @@ 
 #define GIT_CURL_HAVE_CURL_SSLVERSION_TLSv1_0
 #endif
 
+/**
+ * CURLOPT_PROXYHEADER was added in 7.37.0, released in May 2014.
+ */
+#if LIBCURL_VERSION_NUM >= 0x072500
+#define GIT_CURL_HAVE_CURLOPT_PROXYHEADER
+#endif
+
 /**
  * CURLOPT_PINNEDPUBLICKEY was added in 7.39.0, released in November
  * 2014. CURLE_SSL_PINNEDPUBKEYNOTMATCH was added in that same version.
diff --git a/http.c b/http.c
index d59e59f66b..30d5e4c67b 100644
--- a/http.c
+++ b/http.c
@@ -652,8 +652,12 @@  static void set_proxyauth_name_password(CURL *result)
 		curl_easy_setopt(result, CURLOPT_PROXYPASSWORD,
 			proxy_auth.password);
 	} else if (proxy_auth.authtype && proxy_auth.credential) {
+#ifdef GIT_CURL_HAVE_CURLOPT_PROXYHEADER
 		curl_easy_setopt(result, CURLOPT_PROXYHEADER,
 				 http_append_auth_header(&proxy_auth, NULL));
+#else
+		warning(_("CURLOPT_PROXYHEADER not supported with cURL < 7.37.0"));
+#endif
 	}
 }