git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] http: add http.version option to select http protocol version
@ 2018-12-10 22:49 Silvio Fricke
  2018-12-10 23:47 ` Eric Sunshine
  0 siblings, 1 reply; 4+ messages in thread
From: Silvio Fricke @ 2018-12-10 22:49 UTC (permalink / raw)
  To: git; +Cc: Silvio Fricke

HTTP has several protocol versions. By default, libcurl is using HTTP/2
today and check if the remote can use this protocol variant and fall
back to a previous version if not.

Under rare conditions it is needed to switch the used protocol version
to fight again wrongly implemented authorization mechanism like ntlm
with gssapi on remote side.

Signed-off-by: Silvio Fricke <silvio.fricke@gmail.com>
---

Notes:
    I hit a problem with a libcurl (Namely [this bug]). This bug looks
    like never get fixed and to just-use-git from my commandline I don't want
    compile a own libcurl with disabled gssapi or/and http/2.
    
    [this bug]: https://github.com/curl/curl/issues/876

 Documentation/config/http.txt | 10 ++++++++++
 http.c                        | 23 +++++++++++++++++++++++
 2 files changed, 33 insertions(+)

diff --git Documentation/config/http.txt Documentation/config/http.txt
index a56d848bc0..0d2840696b 100644
--- Documentation/config/http.txt
+++ Documentation/config/http.txt
@@ -68,6 +68,16 @@ http.saveCookies::
 	If set, store cookies received during requests to the file specified by
 	http.cookieFile. Has no effect if http.cookieFile is unset.
 
+http.version::
+	If set, use the specific http(s) protocol version.
+	Actually this versions are possible:
+
+	- 2.0 -> HTTP/2
+	- 2   -> HTTP/2
+	- 1.1 -> HTTP/1.1
+	- 1.0 -> HTTP/1.0
+	- 1   -> HTTP/1.0
+
 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 http.c http.c
index eacc2a75ef..99cdd327a5 100644
--- http.c
+++ http.c
@@ -83,6 +83,7 @@ static const char *ssl_cainfo;
 static long curl_low_speed_limit = -1;
 static long curl_low_speed_time = -1;
 static int curl_ftp_no_epsv;
+static const char *curl_http_version;
 static const char *curl_http_proxy;
 static const char *http_proxy_authmethod;
 static struct {
@@ -355,6 +356,10 @@ static int http_options(const char *var, const char *value, void *cb)
 		curl_ftp_no_epsv = git_config_bool(var, value);
 		return 0;
 	}
+
+	if (!strcmp("http.version", var))
+		return git_config_string(&curl_http_version, var, value);
+
 	if (!strcmp("http.proxy", var))
 		return git_config_string(&curl_http_proxy, var, value);
 
@@ -926,6 +931,19 @@ static CURL *get_curl_handle(void)
 	if (curl_ftp_no_epsv)
 		curl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0);
 
+	if (curl_http_version) {
+		if (!strcmp(curl_http_version, "2") || !strcmp(curl_http_version, "2.0"))
+			curl_easy_setopt(result, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
+		else if (!strcmp(curl_http_version, "2TLS"))
+			curl_easy_setopt(result, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2TLS);
+		else if (!strcmp(curl_http_version, "1.1"))
+			curl_easy_setopt(result, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
+		else if (!strcmp(curl_http_version, "1.0") || strcmp(curl_http_version, "1"))
+			curl_easy_setopt(result, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);
+		else
+			warning(_("Use default http(s) protocol"));
+	}
+
 #ifdef CURLOPT_USE_SSL
 	if (curl_ssl_try)
 		curl_easy_setopt(result, CURLOPT_USE_SSL, CURLUSESSL_TRY);
@@ -1169,6 +1187,11 @@ void http_cleanup(void)
 	curl_slist_free_all(no_pragma_header);
 	no_pragma_header = NULL;
 
+	if (curl_http_version) {
+		free((void *)curl_http_version);
+		curl_http_version = NULL;
+	}
+
 	if (curl_http_proxy) {
 		free((void *)curl_http_proxy);
 		curl_http_proxy = NULL;
-- 
2.19.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] http: add http.version option to select http protocol version
  2018-12-10 22:49 [PATCH] http: add http.version option to select http protocol version Silvio Fricke
@ 2018-12-10 23:47 ` Eric Sunshine
  2018-12-11  6:56   ` S. Fricke
  2018-12-11 12:40   ` Johannes Schindelin
  0 siblings, 2 replies; 4+ messages in thread
From: Eric Sunshine @ 2018-12-10 23:47 UTC (permalink / raw)
  To: silvio.fricke; +Cc: Git List

On Mon, Dec 10, 2018 at 5:50 PM Silvio Fricke <silvio.fricke@gmail.com> wrote:
> HTTP has several protocol versions. By default, libcurl is using HTTP/2
> today and check if the remote can use this protocol variant and fall
> back to a previous version if not.
>
> Under rare conditions it is needed to switch the used protocol version
> to fight again wrongly implemented authorization mechanism like ntlm
> with gssapi on remote side.
>
> Signed-off-by: Silvio Fricke <silvio.fricke@gmail.com>

This looks very similar to [1] which is already in Junio's "next"
branch (although not yet in a released version of Git).

[1]: https://public-inbox.org/git/71f8b71b346f132d0dc9a23c9a7f2ca2cb91966f.1541735051.git.gitgitgadget@gmail.com/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] http: add http.version option to select http protocol version
  2018-12-10 23:47 ` Eric Sunshine
@ 2018-12-11  6:56   ` S. Fricke
  2018-12-11 12:40   ` Johannes Schindelin
  1 sibling, 0 replies; 4+ messages in thread
From: S. Fricke @ 2018-12-11  6:56 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Git List

Hi Eric,


> On Mon, Dec 10, 2018 at 5:50 PM Silvio Fricke <silvio.fricke@gmail.com> wrote:
> > HTTP has several protocol versions. By default, libcurl is using HTTP/2

[...]

> This looks very similar to [1] which is already in Junio's "next"
> branch (although not yet in a released version of Git).
> 
> [1]: https://public-inbox.org/git/71f8b71b346f132d0dc9a23c9a7f2ca2cb91966f.1541735051.git.gitgitgadget@gmail.com/

Thanks for the pointer. Looks like I need todo more search than to develop
solutions. ^^

The 8th patch version from charlieio@outlook.com looks better than my
implementation.

Thanks and bye,
Silvio


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] http: add http.version option to select http protocol version
  2018-12-10 23:47 ` Eric Sunshine
  2018-12-11  6:56   ` S. Fricke
@ 2018-12-11 12:40   ` Johannes Schindelin
  1 sibling, 0 replies; 4+ messages in thread
From: Johannes Schindelin @ 2018-12-11 12:40 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: silvio.fricke, Git List

Hi Eric,

On Mon, 10 Dec 2018, Eric Sunshine wrote:

> On Mon, Dec 10, 2018 at 5:50 PM Silvio Fricke <silvio.fricke@gmail.com> wrote:
> > HTTP has several protocol versions. By default, libcurl is using HTTP/2
> > today and check if the remote can use this protocol variant and fall
> > back to a previous version if not.
> >
> > Under rare conditions it is needed to switch the used protocol version
> > to fight again wrongly implemented authorization mechanism like ntlm
> > with gssapi on remote side.

Please note that this has been addressed for NTLM in
https://github.com/curl/curl/pull/3345 and the gssapi problem is probably
worked around by https://github.com/curl/curl/pull/3349.

Both patches were backported to the cURL version included in Git for
Windows v2.20.0.

> > Signed-off-by: Silvio Fricke <silvio.fricke@gmail.com>
> 
> This looks very similar to [1] which is already in Junio's "next"
> branch (although not yet in a released version of Git).

Small correction: it is in Git *for Windows* v2.20.0, so in a manner of
speaking it *is* in a released version of Git.

The reason: even if we included the NTLM/Kerberos patches in Git for
Windows, there might be other scenarios where neither of those patches
catch.

Ciao,
Johannes

> [1]: https://public-inbox.org/git/71f8b71b346f132d0dc9a23c9a7f2ca2cb91966f.1541735051.git.gitgitgadget@gmail.com/
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-12-11 12:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-10 22:49 [PATCH] http: add http.version option to select http protocol version Silvio Fricke
2018-12-10 23:47 ` Eric Sunshine
2018-12-11  6:56   ` S. Fricke
2018-12-11 12:40   ` Johannes Schindelin

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).