{"thread":{"id":"49997","subject":"[PATCH] http: add http.version option to select http protocol version","startedAt":"2018-12-10T22:50:00Z","lastAt":"2018-12-11T12:40:06Z","messageCount":4,"participants":["Silvio Fricke","Eric Sunshine","S. Fricke","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"364986","messageId":"98295da2b5295795414eaf85a40b9ae62b1b2dca.1544482124.git.silvio.fricke@gmail.com","threadId":"49997","inReplyTo":null,"subject":"[PATCH] http: add http.version option to select http protocol version","fromName":"Silvio Fricke","fromEmail":"silvio.fricke@gmail.com","sentAt":"2018-12-10T22:49:14Z","receivedAt":"2018-12-10T22:50:00Z","isPatch":true,"sender":{"key":"silvio.fricke@gmail.com","avatar":"https://gravatar.com/avatar/a0b11e9a9041f02be2ae08f4e7bd1448f11254d73bdad8aef9ebc6ae6979e5c3?d=mp&s=160"},"body":"HTTP has several protocol versions. By default, libcurl is using HTTP/2\ntoday and check if the remote can use this protocol variant and fall\nback to a previous version if not.\n\nUnder rare conditions it is needed to switch the used protocol version\nto fight again wrongly implemented authorization mechanism like ntlm\nwith gssapi on remote side.\n\nSigned-off-by: Silvio Fricke <silvio.fricke@gmail.com>\n---\n\nNotes:\n    I hit a problem with a libcurl (Namely [this bug]). This bug looks\n    like never get fixed and to just-use-git from my commandline I don't want\n    compile a own libcurl with disabled gssapi or/and http/2.\n    \n    [this bug]: https://github.com/curl/curl/issues/876\n\n Documentation/config/http.txt | 10 ++++++++++\n http.c                        | 23 +++++++++++++++++++++++\n 2 files changed, 33 insertions(+)\n\ndiff --git Documentation/config/http.txt Documentation/config/http.txt\nindex a56d848bc0..0d2840696b 100644\n--- Documentation/config/http.txt\n+++ Documentation/config/http.txt\n@@ -68,6 +68,16 @@ http.saveCookies::\n \tIf set, store cookies received during requests to the file specified by\n \thttp.cookieFile. Has no effect if http.cookieFile is unset.\n \n+http.version::\n+\tIf set, use the specific http(s) protocol version.\n+\tActually this versions are possible:\n+\n+\t- 2.0 -> HTTP/2\n+\t- 2   -> HTTP/2\n+\t- 1.1 -> HTTP/1.1\n+\t- 1.0 -> HTTP/1.0\n+\t- 1   -> HTTP/1.0\n+\n http.sslVersion::\n \tThe SSL version to use when negotiating an SSL connection, if you\n \twant to force the default.  The available and default version\ndiff --git http.c http.c\nindex eacc2a75ef..99cdd327a5 100644\n--- http.c\n+++ http.c\n@@ -83,6 +83,7 @@ static const char *ssl_cainfo;\n static long curl_low_speed_limit = -1;\n static long curl_low_speed_time = -1;\n static int curl_ftp_no_epsv;\n+static const char *curl_http_version;\n static const char *curl_http_proxy;\n static const char *http_proxy_authmethod;\n static struct {\n@@ -355,6 +356,10 @@ static int http_options(const char *var, const char *value, void *cb)\n \t\tcurl_ftp_no_epsv = git_config_bool(var, value);\n \t\treturn 0;\n \t}\n+\n+\tif (!strcmp(\"http.version\", var))\n+\t\treturn git_config_string(&curl_http_version, var, value);\n+\n \tif (!strcmp(\"http.proxy\", var))\n \t\treturn git_config_string(&curl_http_proxy, var, value);\n \n@@ -926,6 +931,19 @@ static CURL *get_curl_handle(void)\n \tif (curl_ftp_no_epsv)\n \t\tcurl_easy_setopt(result, CURLOPT_FTP_USE_EPSV, 0);\n \n+\tif (curl_http_version) {\n+\t\tif (!strcmp(curl_http_version, \"2\") || !strcmp(curl_http_version, \"2.0\"))\n+\t\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);\n+\t\telse if (!strcmp(curl_http_version, \"2TLS\"))\n+\t\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2TLS);\n+\t\telse if (!strcmp(curl_http_version, \"1.1\"))\n+\t\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);\n+\t\telse if (!strcmp(curl_http_version, \"1.0\") || strcmp(curl_http_version, \"1\"))\n+\t\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0);\n+\t\telse\n+\t\t\twarning(_(\"Use default http(s) protocol\"));\n+\t}\n+\n #ifdef CURLOPT_USE_SSL\n \tif (curl_ssl_try)\n \t\tcurl_easy_setopt(result, CURLOPT_USE_SSL, CURLUSESSL_TRY);\n@@ -1169,6 +1187,11 @@ void http_cleanup(void)\n \tcurl_slist_free_all(no_pragma_header);\n \tno_pragma_header = NULL;\n \n+\tif (curl_http_version) {\n+\t\tfree((void *)curl_http_version);\n+\t\tcurl_http_version = NULL;\n+\t}\n+\n \tif (curl_http_proxy) {\n \t\tfree((void *)curl_http_proxy);\n \t\tcurl_http_proxy = NULL;\n-- \n2.19.2\n\n"},{"id":"364995","messageId":"CAPig+cQW5_9fH-P8X50Mx5kGJRwEOskw2L49Ajk+3D4xWpcOHg@mail.gmail.com","threadId":"49997","inReplyTo":"98295da2b5295795414eaf85a40b9ae62b1b2dca.1544482124.git.silvio.fricke@gmail.com","subject":"Re: [PATCH] http: add http.version option to select http protocol version","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2018-12-10T23:47:54Z","receivedAt":"2018-12-10T23:48:09Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Mon, Dec 10, 2018 at 5:50 PM Silvio Fricke <silvio.fricke@gmail.com> wrote:\n> HTTP has several protocol versions. By default, libcurl is using HTTP/2\n> today and check if the remote can use this protocol variant and fall\n> back to a previous version if not.\n>\n> Under rare conditions it is needed to switch the used protocol version\n> to fight again wrongly implemented authorization mechanism like ntlm\n> with gssapi on remote side.\n>\n> Signed-off-by: Silvio Fricke <silvio.fricke@gmail.com>\n\nThis looks very similar to [1] which is already in Junio's \"next\"\nbranch (although not yet in a released version of Git).\n\n[1]: https://public-inbox.org/git/71f8b71b346f132d0dc9a23c9a7f2ca2cb91966f.1541735051.git.gitgitgadget@gmail.com/\n"},{"id":"365043","messageId":"20181211065617.nuvpoxdhuqgwcbrv@sfserver","threadId":"49997","inReplyTo":"CAPig+cQW5_9fH-P8X50Mx5kGJRwEOskw2L49Ajk+3D4xWpcOHg@mail.gmail.com","subject":"Re: [PATCH] http: add http.version option to select http protocol version","fromName":"S. Fricke","fromEmail":"silvio.fricke@gmail.com","sentAt":"2018-12-11T06:56:17Z","receivedAt":"2018-12-11T06:56:23Z","isPatch":true,"sender":{"key":"silvio.fricke@gmail.com","avatar":"https://gravatar.com/avatar/a0b11e9a9041f02be2ae08f4e7bd1448f11254d73bdad8aef9ebc6ae6979e5c3?d=mp&s=160"},"body":"Hi Eric,\n\n\n> On Mon, Dec 10, 2018 at 5:50 PM Silvio Fricke <silvio.fricke@gmail.com> wrote:\n> > HTTP has several protocol versions. By default, libcurl is using HTTP/2\n\n[...]\n\n> This looks very similar to [1] which is already in Junio's \"next\"\n> branch (although not yet in a released version of Git).\n> \n> [1]: https://public-inbox.org/git/71f8b71b346f132d0dc9a23c9a7f2ca2cb91966f.1541735051.git.gitgitgadget@gmail.com/\n\nThanks for the pointer. Looks like I need todo more search than to develop\nsolutions. ^^\n\nThe 8th patch version from charlieio@outlook.com looks better than my\nimplementation.\n\nThanks and bye,\nSilvio\n\n"},{"id":"365070","messageId":"nycvar.QRO.7.76.6.1812111334260.43@tvgsbejvaqbjf.bet","threadId":"49997","inReplyTo":"CAPig+cQW5_9fH-P8X50Mx5kGJRwEOskw2L49Ajk+3D4xWpcOHg@mail.gmail.com","subject":"Re: [PATCH] http: add http.version option to select http protocol version","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2018-12-11T12:40:00Z","receivedAt":"2018-12-11T12:40:06Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi Eric,\n\nOn Mon, 10 Dec 2018, Eric Sunshine wrote:\n\n> On Mon, Dec 10, 2018 at 5:50 PM Silvio Fricke <silvio.fricke@gmail.com> wrote:\n> > HTTP has several protocol versions. By default, libcurl is using HTTP/2\n> > today and check if the remote can use this protocol variant and fall\n> > back to a previous version if not.\n> >\n> > Under rare conditions it is needed to switch the used protocol version\n> > to fight again wrongly implemented authorization mechanism like ntlm\n> > with gssapi on remote side.\n\nPlease note that this has been addressed for NTLM in\nhttps://github.com/curl/curl/pull/3345 and the gssapi problem is probably\nworked around by https://github.com/curl/curl/pull/3349.\n\nBoth patches were backported to the cURL version included in Git for\nWindows v2.20.0.\n\n> > Signed-off-by: Silvio Fricke <silvio.fricke@gmail.com>\n> \n> This looks very similar to [1] which is already in Junio's \"next\"\n> branch (although not yet in a released version of Git).\n\nSmall correction: it is in Git *for Windows* v2.20.0, so in a manner of\nspeaking it *is* in a released version of Git.\n\nThe reason: even if we included the NTLM/Kerberos patches in Git for\nWindows, there might be other scenarios where neither of those patches\ncatch.\n\nCiao,\nJohannes\n\n> [1]: https://public-inbox.org/git/71f8b71b346f132d0dc9a23c9a7f2ca2cb91966f.1541735051.git.gitgitgadget@gmail.com/\n> \n"}]}