@@ -48,6 +48,7 @@ char curl_errorstr[CURL_ERROR_SIZE];
48
48
49
49
static int curl_ssl_verify = -1 ;
50
50
static int curl_ssl_try ;
51
+ static const char * curl_http_version = NULL ;
51
52
static const char * ssl_cert ;
52
53
static const char * ssl_cipherlist ;
53
54
static const char * ssl_version ;
@@ -284,6 +285,9 @@ static void process_curl_messages(void)
284
285
285
286
static int http_options (const char * var , const char * value , void * cb )
286
287
{
288
+ if (!strcmp ("http.version" , var )) {
289
+ return git_config_string (& curl_http_version , var , value );
290
+ }
287
291
if (!strcmp ("http.sslverify" , var )) {
288
292
curl_ssl_verify = git_config_bool (var , value );
289
293
return 0 ;
@@ -789,6 +793,31 @@ static long get_curl_allowed_protocols(int from_user)
789
793
}
790
794
#endif
791
795
796
+ #if LIBCURL_VERSION_NUM >=0x072f00
797
+ static int get_curl_http_version_opt (const char * version_string , long * opt )
798
+ {
799
+ int i ;
800
+ static struct {
801
+ const char * name ;
802
+ long opt_token ;
803
+ } choice [] = {
804
+ { "HTTP/1.1" , CURL_HTTP_VERSION_1_1 },
805
+ { "HTTP/2" , CURL_HTTP_VERSION_2 }
806
+ };
807
+
808
+ for (i = 0 ; i < ARRAY_SIZE (choice ); i ++ ) {
809
+ if (!strcmp (version_string , choice [i ].name )) {
810
+ * opt = choice [i ].opt_token ;
811
+ return 0 ;
812
+ }
813
+ }
814
+
815
+ warning ("unknown value given to http.version: '%s'" , version_string );
816
+ return -1 ; /* not found */
817
+ }
818
+
819
+ #endif
820
+
792
821
static CURL * get_curl_handle (void )
793
822
{
794
823
CURL * result = curl_easy_init ();
@@ -806,6 +835,16 @@ static CURL *get_curl_handle(void)
806
835
curl_easy_setopt (result , CURLOPT_SSL_VERIFYHOST , 2 );
807
836
}
808
837
838
+ #if LIBCURL_VERSION_NUM >= 0x072f00 // 7.47.0
839
+ if (curl_http_version ) {
840
+ long opt ;
841
+ if (!get_curl_http_version_opt (curl_http_version , & opt )) {
842
+ /* Set request use http version */
843
+ curl_easy_setopt (result , CURLOPT_HTTP_VERSION , opt );
844
+ }
845
+ }
846
+ #endif
847
+
809
848
#if LIBCURL_VERSION_NUM >= 0x070907
810
849
curl_easy_setopt (result , CURLOPT_NETRC , CURL_NETRC_OPTIONAL );
811
850
#endif
0 commit comments