Subject: [PATCH v5 0/1] http: add support selecting http version

From: "Force.Charlie-I via GitGitGadget" <[email-masked]>
Date: Wed, 07 Nov 2018 22:18:40 -0800 (PST)

Normally, git doesn't need to set curl to select the HTTP version, it works
fine without HTTP/2. Adding HTTP/2 support is a icing on the cake.

This patch support force enable HTTP/2 or HTTP/1.1. 

example: 

GIT_CURL_VERBOSE=1 git2 -c http.version=HTTP/2 ls-remote https://bitbucket.org/aquariusjay/deeplab-public-ver2.git

Force Charlie (1):
  http: add support selecting http version

 http.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

base-commit: 8858448bb49332d353febc078ce4a3abcc962efe
Published-As: https://github.com/gitgitgadget/git/releases/tags/pr-69%2Ffcharlie%2Fmaster-v5
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-69/fcharlie/master-v5
Pull-Request: https://github.com/gitgitgadget/git/pull/69

Range-diff vs v4:

 1:  4f5a935c43 < -:  ---------- http: add support selecting http version
 2:  06e9685d2b < -:  ---------- support force use http 1.1
 3:  eee67d8356 < -:  ---------- fix curl version to support CURL_HTTP_VERSION_2TLS
 4:  0a7794722b ! 1:  cdd93048ba http: change http.version value type
     @@ -1,6 +1,6 @@
      Author: Force Charlie <[email-masked]>
      
     -    http: change http.version value type
     +    http: add support selecting http version
      
          Signed-off-by: Force Charlie <[email-masked]>
      
     @@ -11,21 +11,20 @@
       
       static int curl_ssl_verify = -1;
       static int curl_ssl_try;
     --static int curl_http_version = 0;
      +static const char *curl_http_version = NULL;
       static const char *ssl_cert;
       static const char *ssl_cipherlist;
       static const char *ssl_version;
      @@
     + 
       static int http_options(const char *var, const char *value, void *cb)
       {
     - 	if (!strcmp("http.version",var)) {
     --		curl_http_version=git_config_int(var,value);
     --		return 0;
     ++	if (!strcmp("http.version",var)) {
      +		return git_config_string(&curl_http_version, var, value);
     - 	}
     ++	}
       	if (!strcmp("http.sslverify", var)) {
       		curl_ssl_verify = git_config_bool(var, value);
     + 		return 0;
      @@
       }
       #endif
     @@ -58,21 +57,19 @@
       {
       	CURL *result = curl_easy_init();
      @@
     + 		curl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);
       	}
       
     - #if LIBCURL_VERSION_NUM >= 0x072f00 // 7.47.0
     --    // curl_http_version 0 is default.
     --    if (curl_http_version == 20) {
     --		/* Enable HTTP2*/
     --		curl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2TLS);
     --    } else if (curl_http_version == 11) {
     --		curl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1);
     ++#if LIBCURL_VERSION_NUM >= 0x072f00 // 7.47.0
      +    if (curl_http_version) {
      +		long opt;
      +		if (!get_curl_http_version_opt(curl_http_version, &opt)) {
      +			/* Set request use http version */
      +			curl_easy_setopt(result, CURLOPT_HTTP_VERSION,opt);
      +		}
     -     }
     ++    }
     ++#endif
     ++
     + #if LIBCURL_VERSION_NUM >= 0x070907
     + 	curl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
       #endif
     - 

-- 
gitgitgadget