1
1
#include "git-compat-util.h"
2
+ #include "git-curl-compat.h"
2
3
#include "http.h"
3
4
#include "config.h"
4
5
#include "pack.h"
@@ -47,19 +48,19 @@ static struct {
47
48
{ "sslv2" , CURL_SSLVERSION_SSLv2 },
48
49
{ "sslv3" , CURL_SSLVERSION_SSLv3 },
49
50
{ "tlsv1" , CURL_SSLVERSION_TLSv1 },
50
- #if LIBCURL_VERSION_NUM >= 0x072200
51
+ #ifdef GIT_CURL_HAVE_CURL_SSLVERSION_TLSv1_0
51
52
{ "tlsv1.0" , CURL_SSLVERSION_TLSv1_0 },
52
53
{ "tlsv1.1" , CURL_SSLVERSION_TLSv1_1 },
53
54
{ "tlsv1.2" , CURL_SSLVERSION_TLSv1_2 },
54
55
#endif
55
- #if LIBCURL_VERSION_NUM >= 0x073400
56
+ #ifdef GIT_CURL_HAVE_CURL_SSLVERSION_TLSv1_3
56
57
{ "tlsv1.3" , CURL_SSLVERSION_TLSv1_3 },
57
58
#endif
58
59
};
59
60
static const char * ssl_key ;
60
61
static const char * ssl_capath ;
61
62
static const char * curl_no_proxy ;
62
- #if LIBCURL_VERSION_NUM >= 0x072c00
63
+ #ifdef GIT_CURL_HAVE_CURLOPT_PINNEDPUBLICKEY
63
64
static const char * ssl_pinnedkey ;
64
65
#endif
65
66
static const char * ssl_cainfo ;
@@ -373,10 +374,10 @@ static int http_options(const char *var, const char *value, void *cb)
373
374
}
374
375
375
376
if (!strcmp ("http.pinnedpubkey" , var )) {
376
- #if LIBCURL_VERSION_NUM >= 0x072c00
377
+ #ifdef GIT_CURL_HAVE_CURLOPT_PINNEDPUBLICKEY
377
378
return git_config_pathname (& ssl_pinnedkey , var , value );
378
379
#else
379
- warning (_ ("Public key pinning not supported with cURL < 7.44 .0" ));
380
+ warning (_ ("Public key pinning not supported with cURL < 7.39 .0" ));
380
381
return 0 ;
381
382
#endif
382
383
}
@@ -500,7 +501,7 @@ static int has_cert_password(void)
500
501
return 1 ;
501
502
}
502
503
503
- #if LIBCURL_VERSION_NUM >= 0x073400
504
+ #ifdef GIT_CURL_HAVE_CURLOPT_PROXY_KEYPASSWD
504
505
static int has_proxy_cert_password (void )
505
506
{
506
507
if (http_proxy_ssl_cert == NULL || proxy_ssl_cert_password_required != 1 )
@@ -516,7 +517,7 @@ static int has_proxy_cert_password(void)
516
517
}
517
518
#endif
518
519
519
- #if LIBCURL_VERSION_NUM >= 0x071900
520
+ #ifdef GITCURL_HAVE_CURLOPT_TCP_KEEPALIVE
520
521
static void set_curl_keepalive (CURL * c )
521
522
{
522
523
curl_easy_setopt (c , CURLOPT_TCP_KEEPALIVE , 1 );
@@ -536,7 +537,7 @@ static int sockopt_callback(void *client, curl_socket_t fd, curlsocktype type)
536
537
if (rc < 0 )
537
538
warning_errno ("unable to set SO_KEEPALIVE on socket" );
538
539
539
- return 0 ; /* CURL_SOCKOPT_OK only exists since curl 7.21.5 */
540
+ return CURL_SOCKOPT_OK ;
540
541
}
541
542
542
543
static void set_curl_keepalive (CURL * c )
@@ -732,7 +733,7 @@ static long get_curl_allowed_protocols(int from_user)
732
733
return allowed_protocols ;
733
734
}
734
735
735
- #if LIBCURL_VERSION_NUM >= 0x072f00
736
+ #ifdef GIT_CURL_HAVE_CURL_HTTP_VERSION_2
736
737
static int get_curl_http_version_opt (const char * version_string , long * opt )
737
738
{
738
739
int i ;
@@ -774,7 +775,7 @@ static CURL *get_curl_handle(void)
774
775
curl_easy_setopt (result , CURLOPT_SSL_VERIFYHOST , 2 );
775
776
}
776
777
777
- #if LIBCURL_VERSION_NUM >= 0x072f00 // 7.47.0
778
+ #ifdef GIT_CURL_HAVE_CURL_HTTP_VERSION_2
778
779
if (curl_http_version ) {
779
780
long opt ;
780
781
if (!get_curl_http_version_opt (curl_http_version , & opt )) {
@@ -805,7 +806,7 @@ static CURL *get_curl_handle(void)
805
806
806
807
if (http_ssl_backend && !strcmp ("schannel" , http_ssl_backend ) &&
807
808
!http_schannel_check_revoke ) {
808
- #if LIBCURL_VERSION_NUM >= 0x072c00
809
+ #ifdef GIT_CURL_HAVE_CURLSSLOPT_NO_REVOKE
809
810
curl_easy_setopt (result , CURLOPT_SSL_OPTIONS , CURLSSLOPT_NO_REVOKE );
810
811
#else
811
812
warning (_ ("CURLSSLOPT_NO_REVOKE not supported with cURL < 7.44.0" ));
@@ -845,20 +846,20 @@ static CURL *get_curl_handle(void)
845
846
curl_easy_setopt (result , CURLOPT_SSLKEY , ssl_key );
846
847
if (ssl_capath != NULL )
847
848
curl_easy_setopt (result , CURLOPT_CAPATH , ssl_capath );
848
- #if LIBCURL_VERSION_NUM >= 0x072c00
849
+ #ifdef GIT_CURL_HAVE_CURLOPT_PINNEDPUBLICKEY
849
850
if (ssl_pinnedkey != NULL )
850
851
curl_easy_setopt (result , CURLOPT_PINNEDPUBLICKEY , ssl_pinnedkey );
851
852
#endif
852
853
if (http_ssl_backend && !strcmp ("schannel" , http_ssl_backend ) &&
853
854
!http_schannel_use_ssl_cainfo ) {
854
855
curl_easy_setopt (result , CURLOPT_CAINFO , NULL );
855
- #if LIBCURL_VERSION_NUM >= 0x073400
856
+ #ifdef GIT_CURL_HAVE_CURLOPT_PROXY_CAINFO
856
857
curl_easy_setopt (result , CURLOPT_PROXY_CAINFO , NULL );
857
858
#endif
858
859
} else if (ssl_cainfo != NULL || http_proxy_ssl_ca_info != NULL ) {
859
860
if (ssl_cainfo != NULL )
860
861
curl_easy_setopt (result , CURLOPT_CAINFO , ssl_cainfo );
861
- #if LIBCURL_VERSION_NUM >= 0x073400
862
+ #ifdef GIT_CURL_HAVE_CURLOPT_PROXY_CAINFO
862
863
if (http_proxy_ssl_ca_info != NULL )
863
864
curl_easy_setopt (result , CURLOPT_PROXY_CAINFO , http_proxy_ssl_ca_info );
864
865
#endif
@@ -927,7 +928,6 @@ static CURL *get_curl_handle(void)
927
928
*/
928
929
curl_easy_setopt (result , CURLOPT_PROXY , "" );
929
930
} else if (curl_http_proxy ) {
930
- #if LIBCURL_VERSION_NUM >= 0x071800
931
931
if (starts_with (curl_http_proxy , "socks5h" ))
932
932
curl_easy_setopt (result ,
933
933
CURLOPT_PROXYTYPE , CURLPROXY_SOCKS5_HOSTNAME );
@@ -940,8 +940,7 @@ static CURL *get_curl_handle(void)
940
940
else if (starts_with (curl_http_proxy , "socks" ))
941
941
curl_easy_setopt (result ,
942
942
CURLOPT_PROXYTYPE , CURLPROXY_SOCKS4 );
943
- #endif
944
- #if LIBCURL_VERSION_NUM >= 0x073400
943
+ #ifdef GIT_CURL_HAVE_CURLOPT_PROXY_KEYPASSWD
945
944
else if (starts_with (curl_http_proxy , "https ")) {
946
945
curl_easy_setopt (result , CURLOPT_PROXYTYPE , CURLPROXY_HTTPS );
947
946
@@ -1006,7 +1005,7 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
1006
1005
free (normalized_url );
1007
1006
string_list_clear (& config .vars , 1 );
1008
1007
1009
- #if LIBCURL_VERSION_NUM >= 0x073800
1008
+ #ifdef GIT_CURL_HAVE_CURLSSLSET_NO_BACKENDS
1010
1009
if (http_ssl_backend ) {
1011
1010
const curl_ssl_backend * * backends ;
1012
1011
struct strbuf buf = STRBUF_INIT ;
0 commit comments