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

Re: [PATCH v7 1/1] http: add support selecting http version

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 9, 2018, 03:52 UTC
Message-ID
<xmqqefbu6h7g.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<e26fc0d8c77df749c14dd433a0ee66ed1bca17ef.1541718916.git.gitgitgadget@gmail.com>
"Force Charlie via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 9 quoted lines
> +http.version::
> +	Use the specified HTTP protocol version when communicating with a server.
> +	If you want to force the default. The available and default version depend
> +	on libcurl. Actually the possible values of
> +	this option are:
> +
> +	- HTTP/2
> +	- HTTP/1.1
> +

I just wanted to make sure this formats well; it uses the same construct as used to make the list of allowed values for the next entry (sslVersion), so this should be fine.

Thanks.
Show 73 quoted lines
>  http.sslVersion::
>  	The SSL version to use when negotiating an SSL connection, if you
>  	want to force the default.  The available and default version
> diff --git a/http.c b/http.c
> index 3dc8c560d6..c22275bdee 100644
> --- a/http.c
> +++ b/http.c
> @@ -48,6 +48,7 @@ char curl_errorstr[CURL_ERROR_SIZE];
>  
>  static int curl_ssl_verify = -1;
>  static int curl_ssl_try;
> +static const char *curl_http_version = NULL;
>  static const char *ssl_cert;
>  static const char *ssl_cipherlist;
>  static const char *ssl_version;
> @@ -284,6 +285,9 @@ static void process_curl_messages(void)
>  
>  static int http_options(const char *var, const char *value, void *cb)
>  {
> +	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;
> @@ -789,6 +793,30 @@ static long get_curl_allowed_protocols(int from_user)
>  }
>  #endif
>  
> +#if LIBCURL_VERSION_NUM >=0x072f00
> +static int get_curl_http_version_opt(const char *version_string, long *opt)
> +{
> +	int i;
> +	static struct {
> +		const char *name;
> +		long opt_token;
> +	} choice[] = {
> +		{ "HTTP/1.1", CURL_HTTP_VERSION_1_1 },
> +		{ "HTTP/2", CURL_HTTP_VERSION_2 }
> +	};
> +
> +	for (i = 0; i < ARRAY_SIZE(choice); i++) {
> +		if (!strcmp(version_string, choice[i].name)) {
> +			*opt = choice[i].opt_token;
> +			return 0;
> +		}
> +	}
> +
> +	return -1; /* not found */
> +}
> +
> +#endif
> +
>  static CURL *get_curl_handle(void)
>  {
>  	CURL *result = curl_easy_init();
> @@ -806,6 +834,16 @@ static CURL *get_curl_handle(void)
>  		curl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);
>  	}
>  
> +#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
Previous: Force Charlie via GitGitGadgetNext: Force.Charlie-I via GitGitGadget
Message 30 of 33 in “http: add support selecting http version”
  1. 0/1 http: add support selecting http versionForce.Charlie-I via GitGitGadget, Nov 7, 2018
  2. 1/1 http: add support selecting http versionForce Charlie via GitGitGadget, Nov 7, 2018
  3. Junio C HamanoNov 8, 2018
  4. Daniel StenbergNov 7, 2018
  5. brian m. carlsonNov 8, 2018
  6. Junio C HamanoNov 8, 2018
  7. 0/3 http: add support selecting http versionForce.Charlie-I via GitGitGadget, Nov 8, 2018
  8. 1/3 http: add support selecting http versionForce Charlie via GitGitGadget, Nov 8, 2018
  9. 2/3 support force use http 1.1Force Charlie via GitGitGadget, Nov 8, 2018
  10. 3/3 fix curl version to support CURL_HTTP_VERSION_2TLSForce Charlie via GitGitGadget, Nov 8, 2018
  11. 0/4 http: add support selecting http versionForce.Charlie-I via GitGitGadget, Nov 8, 2018
  12. 1/4 http: add support selecting http versionForce Charlie via GitGitGadget, Nov 8, 2018
  13. 2/4 support force use http 1.1Force Charlie via GitGitGadget, Nov 8, 2018
  14. 3/4 fix curl version to support CURL_HTTP_VERSION_2TLSForce Charlie via GitGitGadget, Nov 8, 2018
  15. 4/4 http: change http.version value typeForce Charlie via GitGitGadget, Nov 8, 2018
  16. 0/4 http: add support selecting http versionForce.Charlie-I via GitGitGadget, Nov 8, 2018
  17. 3/4 fix curl version to support CURL_HTTP_VERSION_2TLSForce Charlie via GitGitGadget, Nov 8, 2018
  18. 2/4 support force use http 1.1Force Charlie via GitGitGadget, Nov 8, 2018
  19. 4/4 http: change http.version value typeForce Charlie via GitGitGadget, Nov 8, 2018
  20. 1/4 http: add support selecting http versionForce Charlie via GitGitGadget, Nov 8, 2018
  21. 0/1 http: add support selecting http versionForce.Charlie-I via GitGitGadget, Nov 8, 2018
  22. 1/1 http: add support selecting http versionForce Charlie via GitGitGadget, Nov 8, 2018
  23. 0/1 http: add support selecting http versionForce.Charlie-I via GitGitGadget, Nov 8, 2018
  24. 1/1 http: add support selecting http versionForce Charlie via GitGitGadget, Nov 8, 2018
  25. Eric SunshineNov 8, 2018
  26. Junio C HamanoNov 9, 2018
  27. Junio C HamanoNov 9, 2018
  28. 0/1 http: add support selecting http versionForce.Charlie-I via GitGitGadget, Nov 8, 2018
  29. 1/1 http: add support selecting http versionForce Charlie via GitGitGadget, Nov 8, 2018
  30. Junio C HamanoNov 9, 2018
  31. 0/1 http: add support selecting http versionForce.Charlie-I via GitGitGadget, Nov 9, 2018
  32. 1/1 http: add support selecting http versionForce Charlie via GitGitGadget, Nov 9, 2018
  33. Junio C HamanoNov 8, 2018

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.