{"thread":{"id":"49777","subject":"[PATCH 0/1] http: add support selecting http version","startedAt":"2018-11-07T13:33:57Z","lastAt":"2018-11-09T03:52:14Z","messageCount":33,"participants":["Force.Charlie-I via GitGitGadget","Force Charlie via GitGitGadget","Daniel Stenberg","brian m. carlson","Junio C Hamano","Eric Sunshine"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"362656","messageId":"pull.69.git.gitgitgadget@gmail.com","threadId":"49777","inReplyTo":null,"subject":"[PATCH 0/1] http: add support selecting http version","fromName":"Force.Charlie-I via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-07T13:33:54Z","receivedAt":"2018-11-07T13:33:57Z","isPatch":true,"sender":{"key":"name:Force.Charlie-I","avatar":null},"body":"Normally, git doesn't need to set curl to select the HTTP version, it works\nfine without HTTP2. Adding HTTP2 support is a icing on the cake.\n\nWhen http.version=20 is set, git will attempt to request the server using\nHTTP2. If the remote server does not support HTTP2, it is no different.\nCurrently bitbucket supports HTTP2 and is available for testing.\n\nexample: \n\nGIT_CURL_VERBOSE=1 git2 -c http.version=20 ls-remote https://bitbucket.org/aquariusjay/deeplab-public-ver2.git\n\nForce Charlie (1):\n  http: add support selecting http version\n\n http.c | 12 ++++++++++++\n 1 file changed, 12 insertions(+)\n\n\nbase-commit: 8858448bb49332d353febc078ce4a3abcc962efe\nPublished-As: https://github.com/gitgitgadget/git/releases/tags/pr-69%2Ffcharlie%2Fmaster-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-69/fcharlie/master-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/69\n-- \ngitgitgadget\n"},{"id":"362657","messageId":"4f5a935c4355794effb23c979dcbaf77ed33da26.1541597633.git.gitgitgadget@gmail.com","threadId":"49777","inReplyTo":"pull.69.git.gitgitgadget@gmail.com","subject":"[PATCH 1/1] http: add support selecting http version","fromName":"Force Charlie via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-07T13:33:56Z","receivedAt":"2018-11-07T13:33:59Z","isPatch":true,"sender":{"key":"name:Force Charlie","avatar":null},"body":"From: Force Charlie <charlieio@outlook.com>\n\nSigned-off-by: Force Charlie <charlieio@outlook.com>\n---\n http.c | 12 ++++++++++++\n 1 file changed, 12 insertions(+)\n\ndiff --git a/http.c b/http.c\nindex 3dc8c560d6..99cb04faba 100644\n--- a/http.c\n+++ b/http.c\n@@ -48,6 +48,7 @@ char curl_errorstr[CURL_ERROR_SIZE];\n \n static int curl_ssl_verify = -1;\n static int curl_ssl_try;\n+static int curl_http_version = 11;\n static const char *ssl_cert;\n static const char *ssl_cipherlist;\n static const char *ssl_version;\n@@ -284,6 +285,10 @@ static void process_curl_messages(void)\n \n static int http_options(const char *var, const char *value, void *cb)\n {\n+\tif (!strcmp(\"http.version\",var)) {\n+\t\tcurl_http_version=git_config_int(var,value);\n+\t\treturn 0;\n+\t}\n \tif (!strcmp(\"http.sslverify\", var)) {\n \t\tcurl_ssl_verify = git_config_bool(var, value);\n \t\treturn 0;\n@@ -806,6 +811,13 @@ static CURL *get_curl_handle(void)\n \t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);\n \t}\n \n+#if LIBCURL_VERSION_NUM >= 0x073100\n+\tif(curl_http_version == 20){\n+\t\t/* CURL Enable HTTP2*/\n+\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2);\n+     }\n+#endif\n+\n #if LIBCURL_VERSION_NUM >= 0x070907\n \tcurl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);\n #endif\n-- \ngitgitgadget\n"},{"id":"362659","messageId":"alpine.DEB.2.20.1811071443130.3368@tvnag.unkk.fr","threadId":"49777","inReplyTo":"pull.69.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 0/1] http: add support selecting http version","fromName":"Daniel Stenberg","fromEmail":"daniel@haxx.se","sentAt":"2018-11-07T13:44:51Z","receivedAt":"2018-11-07T13:56:18Z","isPatch":true,"sender":{"key":"daniel@haxx.se","avatar":"https://gravatar.com/avatar/69fdca87edd17cee21ca2e79fc2ff671d644603c3dc27167430f3cd3dbab7ba8?d=mp&s=160"},"body":"On Wed, 7 Nov 2018, Force.Charlie-I via GitGitGadget wrote:\n\n> Normally, git doesn't need to set curl to select the HTTP version, it works \n> fine without HTTP2. Adding HTTP2 support is a icing on the cake.\n\nJust a FYI:\n\nStarting with libcurl 7.62.0 (released a week ago), it now defaults to the \n\"2TLS\" setting unless you tell it otherwise. With 2TLS, libcurl will attempt \nto use HTTP/2 for HTTPS URLs.\n\n-- \n\n  / daniel.haxx.se\n"},{"id":"362687","messageId":"20181108011813.GE890086@genre.crustytoothpaste.net","threadId":"49777","inReplyTo":"alpine.DEB.2.20.1811071443130.3368@tvnag.unkk.fr","subject":"Re: [PATCH 0/1] http: add support selecting http version","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2018-11-08T01:18:13Z","receivedAt":"2018-11-08T01:18:22Z","isPatch":true,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On Wed, Nov 07, 2018 at 02:44:51PM +0100, Daniel Stenberg wrote:\n> On Wed, 7 Nov 2018, Force.Charlie-I via GitGitGadget wrote:\n> \n> > Normally, git doesn't need to set curl to select the HTTP version, it\n> > works fine without HTTP2. Adding HTTP2 support is a icing on the cake.\n> \n> Just a FYI:\n> \n> Starting with libcurl 7.62.0 (released a week ago), it now defaults to the\n> \"2TLS\" setting unless you tell it otherwise. With 2TLS, libcurl will attempt\n> to use HTTP/2 for HTTPS URLs.\n\nWith this information, I think I would rather we rely on libcurl to do\nthis rather than putting it in Git.  Users will automatically get the\nbest supported protocol instead of having to configure it manually.\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"},{"id":"362689","messageId":"pull.69.v2.git.gitgitgadget@gmail.com","threadId":"49777","inReplyTo":"pull.69.git.gitgitgadget@gmail.com","subject":"[PATCH v2 0/3] http: add support selecting http version","fromName":"Force.Charlie-I via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-08T01:35:02Z","receivedAt":"2018-11-08T01:35:05Z","isPatch":true,"sender":{"key":"name:Force.Charlie-I","avatar":null},"body":"Normally, git doesn't need to set curl to select the HTTP version, it works\nfine without HTTP2. Adding HTTP2 support is a icing on the cake.\n\nWhen http.version=20 is set, git will attempt to request the server using\nHTTP2. If the remote server does not support HTTP2, it is no different.\nCurrently bitbucket supports HTTP2 and is available for testing.\n\nexample: \n\nGIT_CURL_VERBOSE=1 git2 -c http.version=20 ls-remote https://bitbucket.org/aquariusjay/deeplab-public-ver2.git\n\nForce Charlie (3):\n  http: add support selecting http version\n  support force use http 1.1\n  fix curl version to support CURL_HTTP_VERSION_2TLS\n\n http.c | 15 +++++++++++++++\n 1 file changed, 15 insertions(+)\n\n\nbase-commit: 8858448bb49332d353febc078ce4a3abcc962efe\nPublished-As: https://github.com/gitgitgadget/git/releases/tags/pr-69%2Ffcharlie%2Fmaster-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-69/fcharlie/master-v2\nPull-Request: https://github.com/gitgitgadget/git/pull/69\n\nRange-diff vs v1:\n\n 1:  4f5a935c43 = 1:  4f5a935c43 http: add support selecting http version\n -:  ---------- > 2:  06e9685d2b support force use http 1.1\n -:  ---------- > 3:  eee67d8356 fix curl version to support CURL_HTTP_VERSION_2TLS\n\n-- \ngitgitgadget\n"},{"id":"362690","messageId":"4f5a935c4355794effb23c979dcbaf77ed33da26.1541640900.git.gitgitgadget@gmail.com","threadId":"49777","inReplyTo":"pull.69.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 1/3] http: add support selecting http version","fromName":"Force Charlie via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-08T01:35:03Z","receivedAt":"2018-11-08T01:35:06Z","isPatch":true,"sender":{"key":"name:Force Charlie","avatar":null},"body":"From: Force Charlie <charlieio@outlook.com>\n\nSigned-off-by: Force Charlie <charlieio@outlook.com>\n---\n http.c | 12 ++++++++++++\n 1 file changed, 12 insertions(+)\n\ndiff --git a/http.c b/http.c\nindex 3dc8c560d6..99cb04faba 100644\n--- a/http.c\n+++ b/http.c\n@@ -48,6 +48,7 @@ char curl_errorstr[CURL_ERROR_SIZE];\n \n static int curl_ssl_verify = -1;\n static int curl_ssl_try;\n+static int curl_http_version = 11;\n static const char *ssl_cert;\n static const char *ssl_cipherlist;\n static const char *ssl_version;\n@@ -284,6 +285,10 @@ static void process_curl_messages(void)\n \n static int http_options(const char *var, const char *value, void *cb)\n {\n+\tif (!strcmp(\"http.version\",var)) {\n+\t\tcurl_http_version=git_config_int(var,value);\n+\t\treturn 0;\n+\t}\n \tif (!strcmp(\"http.sslverify\", var)) {\n \t\tcurl_ssl_verify = git_config_bool(var, value);\n \t\treturn 0;\n@@ -806,6 +811,13 @@ static CURL *get_curl_handle(void)\n \t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);\n \t}\n \n+#if LIBCURL_VERSION_NUM >= 0x073100\n+\tif(curl_http_version == 20){\n+\t\t/* CURL Enable HTTP2*/\n+\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2);\n+     }\n+#endif\n+\n #if LIBCURL_VERSION_NUM >= 0x070907\n \tcurl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);\n #endif\n-- \ngitgitgadget\n\n"},{"id":"362691","messageId":"06e9685d2bcef99d6635bd928845156b1580062f.1541640900.git.gitgitgadget@gmail.com","threadId":"49777","inReplyTo":"pull.69.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 2/3] support force use http 1.1","fromName":"Force Charlie via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-08T01:35:04Z","receivedAt":"2018-11-08T01:35:08Z","isPatch":true,"sender":{"key":"name:Force Charlie","avatar":null},"body":"From: Force Charlie <charlieio@outlook.com>\n\nSigned-off-by: Force Charlie <charlieio@outlook.com>\n---\n http.c | 15 +++++++++------\n 1 file changed, 9 insertions(+), 6 deletions(-)\n\ndiff --git a/http.c b/http.c\nindex 99cb04faba..b2ec31aef5 100644\n--- a/http.c\n+++ b/http.c\n@@ -48,7 +48,7 @@ char curl_errorstr[CURL_ERROR_SIZE];\n \n static int curl_ssl_verify = -1;\n static int curl_ssl_try;\n-static int curl_http_version = 11;\n+static int curl_http_version = 0;\n static const char *ssl_cert;\n static const char *ssl_cipherlist;\n static const char *ssl_version;\n@@ -811,11 +811,14 @@ static CURL *get_curl_handle(void)\n \t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);\n \t}\n \n-#if LIBCURL_VERSION_NUM >= 0x073100\n-\tif(curl_http_version == 20){\n-\t\t/* CURL Enable HTTP2*/\n-\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2);\n-     }\n+#if LIBCURL_VERSION_NUM >= 0x074700\n+    // curl_http_version 0 is default.\n+    if (curl_http_version == 20) {\n+\t\t/* Enable HTTP2 when request TLS*/\n+\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2TLS);\n+    } else if (curl_http_version == 11) {\n+\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1);\n+    }\n #endif\n \n #if LIBCURL_VERSION_NUM >= 0x070907\n-- \ngitgitgadget\n\n"},{"id":"362692","messageId":"eee67d835653a3902e7f788e4dfb1c6ba8132b8b.1541640900.git.gitgitgadget@gmail.com","threadId":"49777","inReplyTo":"pull.69.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 3/3] fix curl version to support CURL_HTTP_VERSION_2TLS","fromName":"Force Charlie via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-08T01:35:05Z","receivedAt":"2018-11-08T01:35:09Z","isPatch":true,"sender":{"key":"name:Force Charlie","avatar":null},"body":"From: Force Charlie <charlieio@outlook.com>\n\nSigned-off-by: Force Charlie <charlieio@outlook.com>\n---\n http.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/http.c b/http.c\nindex b2ec31aef5..86e454cff5 100644\n--- a/http.c\n+++ b/http.c\n@@ -811,10 +811,10 @@ static CURL *get_curl_handle(void)\n \t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);\n \t}\n \n-#if LIBCURL_VERSION_NUM >= 0x074700\n+#if LIBCURL_VERSION_NUM >= 0x072f00 // 7.47.0\n     // curl_http_version 0 is default.\n     if (curl_http_version == 20) {\n-\t\t/* Enable HTTP2 when request TLS*/\n+\t\t/* Enable HTTP2*/\n \t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2TLS);\n     } else if (curl_http_version == 11) {\n \t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1);\n-- \ngitgitgadget\n"},{"id":"362693","messageId":"xmqqwopo8hm7.fsf@gitster-ct.c.googlers.com","threadId":"49777","inReplyTo":"4f5a935c4355794effb23c979dcbaf77ed33da26.1541597633.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 1/1] http: add support selecting http version","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-11-08T01:48:00Z","receivedAt":"2018-11-08T01:48:05Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Force Charlie via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Force Charlie <charlieio@outlook.com>\n>\n> Signed-off-by: Force Charlie <charlieio@outlook.com>\n> ---\n>  http.c | 12 ++++++++++++\n>  1 file changed, 12 insertions(+)\n>\n> diff --git a/http.c b/http.c\n> index 3dc8c560d6..99cb04faba 100644\n> --- a/http.c\n> +++ b/http.c\n> @@ -48,6 +48,7 @@ char curl_errorstr[CURL_ERROR_SIZE];\n>  \n>  static int curl_ssl_verify = -1;\n>  static int curl_ssl_try;\n> +static int curl_http_version = 11;\n\nIs there any reason that we need to have this variable's value to be\n\"int\"?  I _think_ in this patch, the variable is used to choose\nbetween the default and \"HTTP/2\", and I do not think the updated\ncode can choose any other new value that may be supported by an even\nnewer cURL library without further update, i.e. we'd need a variant of\n\"if the configuration asks HTTP/2 then use CURLOPT_HTTP_VERSION with\nCURL_HTTP_VERSION_2\" for the new choice.\n\nSo I'd think it would not add much value to force end users use a\nrather cryptic \"20\" (vs \"11\") to choose between \"2\" and \"1.1\".  Why\nnot use spell it out, e.g. using the official name of the protocol\n\"HTTP/2\" (vs \"HTTP/1.1\"), with a \"const char *\" instead?\n\nThe new configuration variable and the possible values it can take\nmust be documented, of course.  I think it would make the description\nfar less embarrassing if we say \"HTTP/2\" etc. rather than \"20\",\n\"11\", etc.\n\n> @@ -284,6 +285,10 @@ static void process_curl_messages(void)\n>  \n>  static int http_options(const char *var, const char *value, void *cb)\n>  {\n> +\tif (!strcmp(\"http.version\",var)) {\n> +\t\tcurl_http_version=git_config_int(var,value);\n\nSTYLE.  Missing SP after comma, and around assignment.\n\n> +\t\treturn 0;\n> +\t}\n>  \tif (!strcmp(\"http.sslverify\", var)) {\n>  \t\tcurl_ssl_verify = git_config_bool(var, value);\n>  \t\treturn 0;\n> @@ -806,6 +811,13 @@ static CURL *get_curl_handle(void)\n>  \t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);\n>  \t}\n>  \n> +#if LIBCURL_VERSION_NUM >= 0x073100\n> +\tif(curl_http_version == 20){\n\nSTYLE. Missing SP before opening paren and after closing paren.\n\n> +\t\t/* CURL Enable HTTP2*/\n\nSTYLE. Missing SP before closing asterisk-slash.\n\n> +\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2);\n> +     }\n> +#endif\n\nShouldn't this block also handle the other values, e.g. \"11\"?\n\nI _think_ the curl_http_version variable (be it an deci-int, or a\nconst char *) should be initialized to a value that you can use to\nnotice that the configuration did not specify any, and then this\npart should become more like\n\n\tif (curl_http_version &&\n\t    !get_curl_http_version_opt(curl_http_version, &opt))\n\t\tcurl_easy_setopt(result, CURL_HTTP_VERSION, opt);\n\nwith a helper function like this:\n\nstatic int get_curl_http_version_opt(const char *version_string, long *opt)\n{\t\t\n\tint i;\n\tstatic struct {\n\t\tconst char *name;\n\t\tlnog opt_token;\n\t} choice[] = {\n\t\t{ \"HTTP/1.1\", CURL_HTTP_VERSION_1_1 },\n\t\t{ \"HTTP/2\", CURL_HTTP_VERSION_2 },\n\t};\n\n\tfor (i = 0; i < ARRAY_SIZE(choice); i++) {\n\t\tif (!strcmp(version_string, choice[i].name)) {\n\t\t\t*opt = choice[i].opt_token;\n\t\t\treturn 0;\n\t\t}\n\t}\n\n\treturn -1; /* not found */\n}\n\nwhich would make it trivial to support new values later.\n\n>  #if LIBCURL_VERSION_NUM >= 0x070907\n>  \tcurl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);\n>  #endif\n"},{"id":"362697","messageId":"xmqqd0rg8cmu.fsf@gitster-ct.c.googlers.com","threadId":"49777","inReplyTo":"20181108011813.GE890086@genre.crustytoothpaste.net","subject":"Re: [PATCH 0/1] http: add support selecting http version","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-11-08T03:35:37Z","receivedAt":"2018-11-08T03:35:43Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"brian m. carlson\" <sandals@crustytoothpaste.net> writes:\n\n> On Wed, Nov 07, 2018 at 02:44:51PM +0100, Daniel Stenberg wrote:\n>> On Wed, 7 Nov 2018, Force.Charlie-I via GitGitGadget wrote:\n>> \n>> > Normally, git doesn't need to set curl to select the HTTP version, it\n>> > works fine without HTTP2. Adding HTTP2 support is a icing on the cake.\n>> \n>> Just a FYI:\n>> \n>> Starting with libcurl 7.62.0 (released a week ago), it now defaults to the\n>> \"2TLS\" setting unless you tell it otherwise. With 2TLS, libcurl will attempt\n>> to use HTTP/2 for HTTPS URLs.\n>\n> With this information, I think I would rather we rely on libcurl to do\n> this rather than putting it in Git.  Users will automatically get the\n> best supported protocol instead of having to configure it manually.\n\nYup.  I suspect that the mechanism _might_ turn out to be useful to\nforce downgrading, though.\n"},{"id":"362710","messageId":"pull.69.v3.git.gitgitgadget@gmail.com","threadId":"49777","inReplyTo":"pull.69.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v3 0/4] http: add support selecting http version","fromName":"Force.Charlie-I via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-08T04:54:57Z","receivedAt":"2018-11-08T04:55:03Z","isPatch":true,"sender":{"key":"name:Force.Charlie-I","avatar":null},"body":"Normally, git doesn't need to set curl to select the HTTP version, it works\nfine without HTTP/2. Adding HTTP/2 support is a icing on the cake.\n\nThis patch support force enable HTTP/2 or HTTP/1.1. \n\nexample: \n\nGIT_CURL_VERBOSE=1 git2 -c http.version=HTTP/2 ls-remote https://bitbucket.org/aquariusjay/deeplab-public-ver2.git\n\nForce Charlie (4):\n  http: add support selecting http version\n  support force use http 1.1\n  fix curl version to support CURL_HTTP_VERSION_2TLS\n  http: change http.version value type\n\n http.c | 36 ++++++++++++++++++++++++++++++++++++\n 1 file changed, 36 insertions(+)\n\n\nbase-commit: 8858448bb49332d353febc078ce4a3abcc962efe\nPublished-As: https://github.com/gitgitgadget/git/releases/tags/pr-69%2Ffcharlie%2Fmaster-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-69/fcharlie/master-v3\nPull-Request: https://github.com/gitgitgadget/git/pull/69\n\nRange-diff vs v2:\n\n 1:  4f5a935c43 = 1:  4f5a935c43 http: add support selecting http version\n 2:  06e9685d2b = 2:  06e9685d2b support force use http 1.1\n 3:  eee67d8356 = 3:  eee67d8356 fix curl version to support CURL_HTTP_VERSION_2TLS\n -:  ---------- > 4:  ef975b6093 http: change http.version value type\n\n-- \ngitgitgadget\n"},{"id":"362711","messageId":"4f5a935c4355794effb23c979dcbaf77ed33da26.1541652896.git.gitgitgadget@gmail.com","threadId":"49777","inReplyTo":"pull.69.v3.git.gitgitgadget@gmail.com","subject":"[PATCH v3 1/4] http: add support selecting http version","fromName":"Force Charlie via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-08T04:54:59Z","receivedAt":"2018-11-08T04:55:03Z","isPatch":true,"sender":{"key":"name:Force Charlie","avatar":null},"body":"From: Force Charlie <charlieio@outlook.com>\n\nSigned-off-by: Force Charlie <charlieio@outlook.com>\n---\n http.c | 12 ++++++++++++\n 1 file changed, 12 insertions(+)\n\ndiff --git a/http.c b/http.c\nindex 3dc8c560d6..99cb04faba 100644\n--- a/http.c\n+++ b/http.c\n@@ -48,6 +48,7 @@ char curl_errorstr[CURL_ERROR_SIZE];\n \n static int curl_ssl_verify = -1;\n static int curl_ssl_try;\n+static int curl_http_version = 11;\n static const char *ssl_cert;\n static const char *ssl_cipherlist;\n static const char *ssl_version;\n@@ -284,6 +285,10 @@ static void process_curl_messages(void)\n \n static int http_options(const char *var, const char *value, void *cb)\n {\n+\tif (!strcmp(\"http.version\",var)) {\n+\t\tcurl_http_version=git_config_int(var,value);\n+\t\treturn 0;\n+\t}\n \tif (!strcmp(\"http.sslverify\", var)) {\n \t\tcurl_ssl_verify = git_config_bool(var, value);\n \t\treturn 0;\n@@ -806,6 +811,13 @@ static CURL *get_curl_handle(void)\n \t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);\n \t}\n \n+#if LIBCURL_VERSION_NUM >= 0x073100\n+\tif(curl_http_version == 20){\n+\t\t/* CURL Enable HTTP2*/\n+\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2);\n+     }\n+#endif\n+\n #if LIBCURL_VERSION_NUM >= 0x070907\n \tcurl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);\n #endif\n-- \ngitgitgadget\n\n"},{"id":"362712","messageId":"06e9685d2bcef99d6635bd928845156b1580062f.1541652896.git.gitgitgadget@gmail.com","threadId":"49777","inReplyTo":"pull.69.v3.git.gitgitgadget@gmail.com","subject":"[PATCH v3 2/4] support force use http 1.1","fromName":"Force Charlie via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-08T04:55:00Z","receivedAt":"2018-11-08T04:55:25Z","isPatch":true,"sender":{"key":"name:Force Charlie","avatar":null},"body":"From: Force Charlie <charlieio@outlook.com>\n\nSigned-off-by: Force Charlie <charlieio@outlook.com>\n---\n http.c | 15 +++++++++------\n 1 file changed, 9 insertions(+), 6 deletions(-)\n\ndiff --git a/http.c b/http.c\nindex 99cb04faba..b2ec31aef5 100644\n--- a/http.c\n+++ b/http.c\n@@ -48,7 +48,7 @@ char curl_errorstr[CURL_ERROR_SIZE];\n \n static int curl_ssl_verify = -1;\n static int curl_ssl_try;\n-static int curl_http_version = 11;\n+static int curl_http_version = 0;\n static const char *ssl_cert;\n static const char *ssl_cipherlist;\n static const char *ssl_version;\n@@ -811,11 +811,14 @@ static CURL *get_curl_handle(void)\n \t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);\n \t}\n \n-#if LIBCURL_VERSION_NUM >= 0x073100\n-\tif(curl_http_version == 20){\n-\t\t/* CURL Enable HTTP2*/\n-\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2);\n-     }\n+#if LIBCURL_VERSION_NUM >= 0x074700\n+    // curl_http_version 0 is default.\n+    if (curl_http_version == 20) {\n+\t\t/* Enable HTTP2 when request TLS*/\n+\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2TLS);\n+    } else if (curl_http_version == 11) {\n+\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1);\n+    }\n #endif\n \n #if LIBCURL_VERSION_NUM >= 0x070907\n-- \ngitgitgadget\n\n"},{"id":"362713","messageId":"eee67d835653a3902e7f788e4dfb1c6ba8132b8b.1541652896.git.gitgitgadget@gmail.com","threadId":"49777","inReplyTo":"pull.69.v3.git.gitgitgadget@gmail.com","subject":"[PATCH v3 3/4] fix curl version to support CURL_HTTP_VERSION_2TLS","fromName":"Force Charlie via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-08T04:55:01Z","receivedAt":"2018-11-08T04:55:25Z","isPatch":true,"sender":{"key":"name:Force Charlie","avatar":null},"body":"From: Force Charlie <charlieio@outlook.com>\n\nSigned-off-by: Force Charlie <charlieio@outlook.com>\n---\n http.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/http.c b/http.c\nindex b2ec31aef5..86e454cff5 100644\n--- a/http.c\n+++ b/http.c\n@@ -811,10 +811,10 @@ static CURL *get_curl_handle(void)\n \t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);\n \t}\n \n-#if LIBCURL_VERSION_NUM >= 0x074700\n+#if LIBCURL_VERSION_NUM >= 0x072f00 // 7.47.0\n     // curl_http_version 0 is default.\n     if (curl_http_version == 20) {\n-\t\t/* Enable HTTP2 when request TLS*/\n+\t\t/* Enable HTTP2*/\n \t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2TLS);\n     } else if (curl_http_version == 11) {\n \t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1);\n-- \ngitgitgadget\n\n"},{"id":"362714","messageId":"ef975b60930601f295d1dc6149e63551da211bf0.1541652896.git.gitgitgadget@gmail.com","threadId":"49777","inReplyTo":"pull.69.v3.git.gitgitgadget@gmail.com","subject":"[PATCH v3 4/4] http: change http.version value type","fromName":"Force Charlie via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-08T04:55:02Z","receivedAt":"2018-11-08T04:55:25Z","isPatch":true,"sender":{"key":"name:Force Charlie","avatar":null},"body":"From: Force Charlie <charlieio@outlook.com>\n\nSigned-off-by: Force Charlie <charlieio@outlook.com>\n---\n http.c | 39 ++++++++++++++++++++++++++++++---------\n 1 file changed, 30 insertions(+), 9 deletions(-)\n\ndiff --git a/http.c b/http.c\nindex 86e454cff5..0ad797caea 100644\n--- a/http.c\n+++ b/http.c\n@@ -48,7 +48,7 @@ char curl_errorstr[CURL_ERROR_SIZE];\n \n static int curl_ssl_verify = -1;\n static int curl_ssl_try;\n-static int curl_http_version = 0;\n+static const char *curl_http_version = NULL;\n static const char *ssl_cert;\n static const char *ssl_cipherlist;\n static const char *ssl_version;\n@@ -286,8 +286,7 @@ static void process_curl_messages(void)\n static int http_options(const char *var, const char *value, void *cb)\n {\n \tif (!strcmp(\"http.version\",var)) {\n-\t\tcurl_http_version=git_config_int(var,value);\n-\t\treturn 0;\n+\t\treturn git_config_string(&curl_http_version, var, value);\n \t}\n \tif (!strcmp(\"http.sslverify\", var)) {\n \t\tcurl_ssl_verify = git_config_bool(var, value);\n@@ -794,6 +793,30 @@ static long get_curl_allowed_protocols(int from_user)\n }\n #endif\n \n+#if LIBCURL_VERSION_NUM >=0x072f00\n+static int get_curl_http_version_opt(const char *version_string, long *opt)\n+{\n+\tint i;\n+\tstatic struct {\n+\t\tconst char *name;\n+\t\tlong opt_token;\n+\t} choice[] = {\n+\t\t{ \"HTTP/1.1\", CURL_HTTP_VERSION_1_1 },\n+\t\t{ \"HTTP/2\", CURL_HTTP_VERSION_2 }\n+\t};\n+\n+\tfor (i = 0; i < ARRAY_SIZE(choice); i++) {\n+\t\tif (!strcmp(version_string, choice[i].name)) {\n+\t\t\t*opt = choice[i].opt_token;\n+\t\t\treturn 0;\n+\t\t}\n+\t}\n+\n+\treturn -1; /* not found */\n+}\n+\n+#endif\n+\n static CURL *get_curl_handle(void)\n {\n \tCURL *result = curl_easy_init();\n@@ -812,12 +835,10 @@ static CURL *get_curl_handle(void)\n \t}\n \n #if LIBCURL_VERSION_NUM >= 0x072f00 // 7.47.0\n-    // curl_http_version 0 is default.\n-    if (curl_http_version == 20) {\n-\t\t/* Enable HTTP2*/\n-\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2TLS);\n-    } else if (curl_http_version == 11) {\n-\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1);\n+    long opt=-1;\n+    if (curl_http_version &&!get_curl_http_version_opt(curl_http_version, &opt)) {\n+\t\t/* Set request use http version */\n+\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,opt);\n     }\n #endif\n \n-- \ngitgitgadget\n"},{"id":"362721","messageId":"pull.69.v4.git.gitgitgadget@gmail.com","threadId":"49777","inReplyTo":"pull.69.v3.git.gitgitgadget@gmail.com","subject":"[PATCH v4 0/4] http: add support selecting http version","fromName":"Force.Charlie-I via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-08T06:14:02Z","receivedAt":"2018-11-08T06:14:05Z","isPatch":true,"sender":{"key":"name:Force.Charlie-I","avatar":null},"body":"Normally, git doesn't need to set curl to select the HTTP version, it works\nfine without HTTP/2. Adding HTTP/2 support is a icing on the cake.\n\nThis patch support force enable HTTP/2 or HTTP/1.1. \n\nexample: \n\nGIT_CURL_VERBOSE=1 git2 -c http.version=HTTP/2 ls-remote https://bitbucket.org/aquariusjay/deeplab-public-ver2.git\n\nForce Charlie (4):\n  http: add support selecting http version\n  support force use http 1.1\n  fix curl version to support CURL_HTTP_VERSION_2TLS\n  http: change http.version value type\n\n http.c | 38 ++++++++++++++++++++++++++++++++++++++\n 1 file changed, 38 insertions(+)\n\n\nbase-commit: 8858448bb49332d353febc078ce4a3abcc962efe\nPublished-As: https://github.com/gitgitgadget/git/releases/tags/pr-69%2Ffcharlie%2Fmaster-v4\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-69/fcharlie/master-v4\nPull-Request: https://github.com/gitgitgadget/git/pull/69\n\nRange-diff vs v3:\n\n 1:  4f5a935c43 = 1:  4f5a935c43 http: add support selecting http version\n 2:  06e9685d2b = 2:  06e9685d2b support force use http 1.1\n 3:  eee67d8356 = 3:  eee67d8356 fix curl version to support CURL_HTTP_VERSION_2TLS\n 4:  ef975b6093 ! 4:  0a7794722b http: change http.version value type\n     @@ -67,10 +67,12 @@\n      -\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2TLS);\n      -    } else if (curl_http_version == 11) {\n      -\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1);\n     -+    long opt=-1;\n     -+    if (curl_http_version &&!get_curl_http_version_opt(curl_http_version, &opt)) {\n     -+\t\t/* Set request use http version */\n     -+\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,opt);\n     ++    if (curl_http_version) {\n     ++\t\tlong opt;\n     ++\t\tif (!get_curl_http_version_opt(curl_http_version, &opt)) {\n     ++\t\t\t/* Set request use http version */\n     ++\t\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,opt);\n     ++\t\t}\n           }\n       #endif\n       \n\n-- \ngitgitgadget\n"},{"id":"362722","messageId":"eee67d835653a3902e7f788e4dfb1c6ba8132b8b.1541657640.git.gitgitgadget@gmail.com","threadId":"49777","inReplyTo":"pull.69.v4.git.gitgitgadget@gmail.com","subject":"[PATCH v4 3/4] fix curl version to support CURL_HTTP_VERSION_2TLS","fromName":"Force Charlie via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-08T06:14:06Z","receivedAt":"2018-11-08T06:14:09Z","isPatch":true,"sender":{"key":"name:Force Charlie","avatar":null},"body":"From: Force Charlie <charlieio@outlook.com>\n\nSigned-off-by: Force Charlie <charlieio@outlook.com>\n---\n http.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/http.c b/http.c\nindex b2ec31aef5..86e454cff5 100644\n--- a/http.c\n+++ b/http.c\n@@ -811,10 +811,10 @@ static CURL *get_curl_handle(void)\n \t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);\n \t}\n \n-#if LIBCURL_VERSION_NUM >= 0x074700\n+#if LIBCURL_VERSION_NUM >= 0x072f00 // 7.47.0\n     // curl_http_version 0 is default.\n     if (curl_http_version == 20) {\n-\t\t/* Enable HTTP2 when request TLS*/\n+\t\t/* Enable HTTP2*/\n \t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2TLS);\n     } else if (curl_http_version == 11) {\n \t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1);\n-- \ngitgitgadget\n\n"},{"id":"362723","messageId":"06e9685d2bcef99d6635bd928845156b1580062f.1541657640.git.gitgitgadget@gmail.com","threadId":"49777","inReplyTo":"pull.69.v4.git.gitgitgadget@gmail.com","subject":"[PATCH v4 2/4] support force use http 1.1","fromName":"Force Charlie via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-08T06:14:05Z","receivedAt":"2018-11-08T06:14:10Z","isPatch":true,"sender":{"key":"name:Force Charlie","avatar":null},"body":"From: Force Charlie <charlieio@outlook.com>\n\nSigned-off-by: Force Charlie <charlieio@outlook.com>\n---\n http.c | 15 +++++++++------\n 1 file changed, 9 insertions(+), 6 deletions(-)\n\ndiff --git a/http.c b/http.c\nindex 99cb04faba..b2ec31aef5 100644\n--- a/http.c\n+++ b/http.c\n@@ -48,7 +48,7 @@ char curl_errorstr[CURL_ERROR_SIZE];\n \n static int curl_ssl_verify = -1;\n static int curl_ssl_try;\n-static int curl_http_version = 11;\n+static int curl_http_version = 0;\n static const char *ssl_cert;\n static const char *ssl_cipherlist;\n static const char *ssl_version;\n@@ -811,11 +811,14 @@ static CURL *get_curl_handle(void)\n \t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);\n \t}\n \n-#if LIBCURL_VERSION_NUM >= 0x073100\n-\tif(curl_http_version == 20){\n-\t\t/* CURL Enable HTTP2*/\n-\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2);\n-     }\n+#if LIBCURL_VERSION_NUM >= 0x074700\n+    // curl_http_version 0 is default.\n+    if (curl_http_version == 20) {\n+\t\t/* Enable HTTP2 when request TLS*/\n+\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2TLS);\n+    } else if (curl_http_version == 11) {\n+\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1);\n+    }\n #endif\n \n #if LIBCURL_VERSION_NUM >= 0x070907\n-- \ngitgitgadget\n\n"},{"id":"362724","messageId":"0a7794722be9322dbf696e486d4ff6da7da5bc8b.1541657640.git.gitgitgadget@gmail.com","threadId":"49777","inReplyTo":"pull.69.v4.git.gitgitgadget@gmail.com","subject":"[PATCH v4 4/4] http: change http.version value type","fromName":"Force Charlie via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-08T06:14:07Z","receivedAt":"2018-11-08T06:14:10Z","isPatch":true,"sender":{"key":"name:Force Charlie","avatar":null},"body":"From: Force Charlie <charlieio@outlook.com>\n\nSigned-off-by: Force Charlie <charlieio@outlook.com>\n---\n http.c | 41 ++++++++++++++++++++++++++++++++---------\n 1 file changed, 32 insertions(+), 9 deletions(-)\n\ndiff --git a/http.c b/http.c\nindex 86e454cff5..d6f3c4ee80 100644\n--- a/http.c\n+++ b/http.c\n@@ -48,7 +48,7 @@ char curl_errorstr[CURL_ERROR_SIZE];\n \n static int curl_ssl_verify = -1;\n static int curl_ssl_try;\n-static int curl_http_version = 0;\n+static const char *curl_http_version = NULL;\n static const char *ssl_cert;\n static const char *ssl_cipherlist;\n static const char *ssl_version;\n@@ -286,8 +286,7 @@ static void process_curl_messages(void)\n static int http_options(const char *var, const char *value, void *cb)\n {\n \tif (!strcmp(\"http.version\",var)) {\n-\t\tcurl_http_version=git_config_int(var,value);\n-\t\treturn 0;\n+\t\treturn git_config_string(&curl_http_version, var, value);\n \t}\n \tif (!strcmp(\"http.sslverify\", var)) {\n \t\tcurl_ssl_verify = git_config_bool(var, value);\n@@ -794,6 +793,30 @@ static long get_curl_allowed_protocols(int from_user)\n }\n #endif\n \n+#if LIBCURL_VERSION_NUM >=0x072f00\n+static int get_curl_http_version_opt(const char *version_string, long *opt)\n+{\n+\tint i;\n+\tstatic struct {\n+\t\tconst char *name;\n+\t\tlong opt_token;\n+\t} choice[] = {\n+\t\t{ \"HTTP/1.1\", CURL_HTTP_VERSION_1_1 },\n+\t\t{ \"HTTP/2\", CURL_HTTP_VERSION_2 }\n+\t};\n+\n+\tfor (i = 0; i < ARRAY_SIZE(choice); i++) {\n+\t\tif (!strcmp(version_string, choice[i].name)) {\n+\t\t\t*opt = choice[i].opt_token;\n+\t\t\treturn 0;\n+\t\t}\n+\t}\n+\n+\treturn -1; /* not found */\n+}\n+\n+#endif\n+\n static CURL *get_curl_handle(void)\n {\n \tCURL *result = curl_easy_init();\n@@ -812,12 +835,12 @@ static CURL *get_curl_handle(void)\n \t}\n \n #if LIBCURL_VERSION_NUM >= 0x072f00 // 7.47.0\n-    // curl_http_version 0 is default.\n-    if (curl_http_version == 20) {\n-\t\t/* Enable HTTP2*/\n-\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2TLS);\n-    } else if (curl_http_version == 11) {\n-\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1);\n+    if (curl_http_version) {\n+\t\tlong opt;\n+\t\tif (!get_curl_http_version_opt(curl_http_version, &opt)) {\n+\t\t\t/* Set request use http version */\n+\t\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,opt);\n+\t\t}\n     }\n #endif\n \n-- \ngitgitgadget\n"},{"id":"362725","messageId":"4f5a935c4355794effb23c979dcbaf77ed33da26.1541657640.git.gitgitgadget@gmail.com","threadId":"49777","inReplyTo":"pull.69.v4.git.gitgitgadget@gmail.com","subject":"[PATCH v4 1/4] http: add support selecting http version","fromName":"Force Charlie via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-08T06:14:03Z","receivedAt":"2018-11-08T06:14:12Z","isPatch":true,"sender":{"key":"name:Force Charlie","avatar":null},"body":"From: Force Charlie <charlieio@outlook.com>\n\nSigned-off-by: Force Charlie <charlieio@outlook.com>\n---\n http.c | 12 ++++++++++++\n 1 file changed, 12 insertions(+)\n\ndiff --git a/http.c b/http.c\nindex 3dc8c560d6..99cb04faba 100644\n--- a/http.c\n+++ b/http.c\n@@ -48,6 +48,7 @@ char curl_errorstr[CURL_ERROR_SIZE];\n \n static int curl_ssl_verify = -1;\n static int curl_ssl_try;\n+static int curl_http_version = 11;\n static const char *ssl_cert;\n static const char *ssl_cipherlist;\n static const char *ssl_version;\n@@ -284,6 +285,10 @@ static void process_curl_messages(void)\n \n static int http_options(const char *var, const char *value, void *cb)\n {\n+\tif (!strcmp(\"http.version\",var)) {\n+\t\tcurl_http_version=git_config_int(var,value);\n+\t\treturn 0;\n+\t}\n \tif (!strcmp(\"http.sslverify\", var)) {\n \t\tcurl_ssl_verify = git_config_bool(var, value);\n \t\treturn 0;\n@@ -806,6 +811,13 @@ static CURL *get_curl_handle(void)\n \t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);\n \t}\n \n+#if LIBCURL_VERSION_NUM >= 0x073100\n+\tif(curl_http_version == 20){\n+\t\t/* CURL Enable HTTP2*/\n+\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2);\n+     }\n+#endif\n+\n #if LIBCURL_VERSION_NUM >= 0x070907\n \tcurl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);\n #endif\n-- \ngitgitgadget\n\n"},{"id":"362726","messageId":"xmqqy3a46qpt.fsf@gitster-ct.c.googlers.com","threadId":"49777","inReplyTo":"pull.69.v3.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v3 0/4] http: add support selecting http version","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-11-08T06:14:22Z","receivedAt":"2018-11-08T06:14:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Force.Charlie-I via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> Normally, git doesn't need to set curl to select the HTTP version, it works\n> fine without HTTP/2. Adding HTTP/2 support is a icing on the cake.\n>\n> This patch support force enable HTTP/2 or HTTP/1.1. \n>\n> example: \n>\n> GIT_CURL_VERBOSE=1 git2 -c http.version=HTTP/2 ls-remote https://bitbucket.org/aquariusjay/deeplab-public-ver2.git\n>\n> Force Charlie (4):\n>   http: add support selecting http version\n>   support force use http 1.1\n>   fix curl version to support CURL_HTTP_VERSION_2TLS\n>   http: change http.version value type\n\nWhen somebody reads over these four patches as a first-time reader,\nI think s/he notices a couple of things:\n\n - In the proposed log messages, there is no explanation on the\n   reason why we are doing these changes.\n\n - Each of the steps n/4 (n > 1) looks more like \"oops, it was a\n   mistake that we did not do this in earlier patch, and here is to\n   correct that\".\n\n - There is no test or documentation.\n\nI suspect that a single patch that updates http.c, Documentation/\nand t/ at the same time should be sufficient for a change of this\nsize.\n\nThanks.\n\n\n>  http.c | 36 ++++++++++++++++++++++++++++++++++++\n>  1 file changed, 36 insertions(+)\n>\n>\n> base-commit: 8858448bb49332d353febc078ce4a3abcc962efe\n> Published-As: https://github.com/gitgitgadget/git/releases/tags/pr-69%2Ffcharlie%2Fmaster-v3\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-69/fcharlie/master-v3\n> Pull-Request: https://github.com/gitgitgadget/git/pull/69\n>\n> Range-diff vs v2:\n>\n>  1:  4f5a935c43 = 1:  4f5a935c43 http: add support selecting http version\n>  2:  06e9685d2b = 2:  06e9685d2b support force use http 1.1\n>  3:  eee67d8356 = 3:  eee67d8356 fix curl version to support CURL_HTTP_VERSION_2TLS\n>  -:  ---------- > 4:  ef975b6093 http: change http.version value type\n"},{"id":"362727","messageId":"pull.69.v5.git.gitgitgadget@gmail.com","threadId":"49777","inReplyTo":"pull.69.v4.git.gitgitgadget@gmail.com","subject":"[PATCH v5 0/1] http: add support selecting http version","fromName":"Force.Charlie-I via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-08T06:18:40Z","receivedAt":"2018-11-08T06:18:44Z","isPatch":true,"sender":{"key":"name:Force.Charlie-I","avatar":null},"body":"Normally, git doesn't need to set curl to select the HTTP version, it works\nfine without HTTP/2. Adding HTTP/2 support is a icing on the cake.\n\nThis patch support force enable HTTP/2 or HTTP/1.1. \n\nexample: \n\nGIT_CURL_VERBOSE=1 git2 -c http.version=HTTP/2 ls-remote https://bitbucket.org/aquariusjay/deeplab-public-ver2.git\n\nForce Charlie (1):\n  http: add support selecting http version\n\n http.c | 38 ++++++++++++++++++++++++++++++++++++++\n 1 file changed, 38 insertions(+)\n\n\nbase-commit: 8858448bb49332d353febc078ce4a3abcc962efe\nPublished-As: https://github.com/gitgitgadget/git/releases/tags/pr-69%2Ffcharlie%2Fmaster-v5\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-69/fcharlie/master-v5\nPull-Request: https://github.com/gitgitgadget/git/pull/69\n\nRange-diff vs v4:\n\n 1:  4f5a935c43 < -:  ---------- http: add support selecting http version\n 2:  06e9685d2b < -:  ---------- support force use http 1.1\n 3:  eee67d8356 < -:  ---------- fix curl version to support CURL_HTTP_VERSION_2TLS\n 4:  0a7794722b ! 1:  cdd93048ba http: change http.version value type\n     @@ -1,6 +1,6 @@\n      Author: Force Charlie <charlieio@outlook.com>\n      \n     -    http: change http.version value type\n     +    http: add support selecting http version\n      \n          Signed-off-by: Force Charlie <charlieio@outlook.com>\n      \n     @@ -11,21 +11,20 @@\n       \n       static int curl_ssl_verify = -1;\n       static int curl_ssl_try;\n     --static int curl_http_version = 0;\n      +static const char *curl_http_version = NULL;\n       static const char *ssl_cert;\n       static const char *ssl_cipherlist;\n       static const char *ssl_version;\n      @@\n     + \n       static int http_options(const char *var, const char *value, void *cb)\n       {\n     - \tif (!strcmp(\"http.version\",var)) {\n     --\t\tcurl_http_version=git_config_int(var,value);\n     --\t\treturn 0;\n     ++\tif (!strcmp(\"http.version\",var)) {\n      +\t\treturn git_config_string(&curl_http_version, var, value);\n     - \t}\n     ++\t}\n       \tif (!strcmp(\"http.sslverify\", var)) {\n       \t\tcurl_ssl_verify = git_config_bool(var, value);\n     + \t\treturn 0;\n      @@\n       }\n       #endif\n     @@ -58,21 +57,19 @@\n       {\n       \tCURL *result = curl_easy_init();\n      @@\n     + \t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);\n       \t}\n       \n     - #if LIBCURL_VERSION_NUM >= 0x072f00 // 7.47.0\n     --    // curl_http_version 0 is default.\n     --    if (curl_http_version == 20) {\n     --\t\t/* Enable HTTP2*/\n     --\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2TLS);\n     --    } else if (curl_http_version == 11) {\n     --\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1);\n     ++#if LIBCURL_VERSION_NUM >= 0x072f00 // 7.47.0\n      +    if (curl_http_version) {\n      +\t\tlong opt;\n      +\t\tif (!get_curl_http_version_opt(curl_http_version, &opt)) {\n      +\t\t\t/* Set request use http version */\n      +\t\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,opt);\n      +\t\t}\n     -     }\n     ++    }\n     ++#endif\n     ++\n     + #if LIBCURL_VERSION_NUM >= 0x070907\n     + \tcurl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);\n       #endif\n     - \n\n-- \ngitgitgadget\n"},{"id":"362728","messageId":"cdd93048ba42b0baf085c8da4f8fc8937546bef9.1541657919.git.gitgitgadget@gmail.com","threadId":"49777","inReplyTo":"pull.69.v5.git.gitgitgadget@gmail.com","subject":"[PATCH v5 1/1] http: add support selecting http version","fromName":"Force Charlie via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-08T06:18:42Z","receivedAt":"2018-11-08T06:18:44Z","isPatch":true,"sender":{"key":"name:Force Charlie","avatar":null},"body":"From: Force Charlie <charlieio@outlook.com>\n\nSigned-off-by: Force Charlie <charlieio@outlook.com>\n---\n http.c | 38 ++++++++++++++++++++++++++++++++++++++\n 1 file changed, 38 insertions(+)\n\ndiff --git a/http.c b/http.c\nindex 3dc8c560d6..d6f3c4ee80 100644\n--- a/http.c\n+++ b/http.c\n@@ -48,6 +48,7 @@ char curl_errorstr[CURL_ERROR_SIZE];\n \n static int curl_ssl_verify = -1;\n static int curl_ssl_try;\n+static const char *curl_http_version = NULL;\n static const char *ssl_cert;\n static const char *ssl_cipherlist;\n static const char *ssl_version;\n@@ -284,6 +285,9 @@ static void process_curl_messages(void)\n \n static int http_options(const char *var, const char *value, void *cb)\n {\n+\tif (!strcmp(\"http.version\",var)) {\n+\t\treturn git_config_string(&curl_http_version, var, value);\n+\t}\n \tif (!strcmp(\"http.sslverify\", var)) {\n \t\tcurl_ssl_verify = git_config_bool(var, value);\n \t\treturn 0;\n@@ -789,6 +793,30 @@ static long get_curl_allowed_protocols(int from_user)\n }\n #endif\n \n+#if LIBCURL_VERSION_NUM >=0x072f00\n+static int get_curl_http_version_opt(const char *version_string, long *opt)\n+{\n+\tint i;\n+\tstatic struct {\n+\t\tconst char *name;\n+\t\tlong opt_token;\n+\t} choice[] = {\n+\t\t{ \"HTTP/1.1\", CURL_HTTP_VERSION_1_1 },\n+\t\t{ \"HTTP/2\", CURL_HTTP_VERSION_2 }\n+\t};\n+\n+\tfor (i = 0; i < ARRAY_SIZE(choice); i++) {\n+\t\tif (!strcmp(version_string, choice[i].name)) {\n+\t\t\t*opt = choice[i].opt_token;\n+\t\t\treturn 0;\n+\t\t}\n+\t}\n+\n+\treturn -1; /* not found */\n+}\n+\n+#endif\n+\n static CURL *get_curl_handle(void)\n {\n \tCURL *result = curl_easy_init();\n@@ -806,6 +834,16 @@ static CURL *get_curl_handle(void)\n \t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);\n \t}\n \n+#if LIBCURL_VERSION_NUM >= 0x072f00 // 7.47.0\n+    if (curl_http_version) {\n+\t\tlong opt;\n+\t\tif (!get_curl_http_version_opt(curl_http_version, &opt)) {\n+\t\t\t/* Set request use http version */\n+\t\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,opt);\n+\t\t}\n+    }\n+#endif\n+\n #if LIBCURL_VERSION_NUM >= 0x070907\n \tcurl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);\n #endif\n-- \ngitgitgadget\n"},{"id":"362730","messageId":"pull.69.v6.git.gitgitgadget@gmail.com","threadId":"49777","inReplyTo":"pull.69.v5.git.gitgitgadget@gmail.com","subject":"[PATCH v6 0/1] http: add support selecting http version","fromName":"Force.Charlie-I via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-08T07:00:06Z","receivedAt":"2018-11-08T07:00:09Z","isPatch":true,"sender":{"key":"name:Force.Charlie-I","avatar":null},"body":"Usually we don't need to set libcurl to choose which version of the HTTP\nprotocol to use to communicate with a server. But different versions of\nlibcurl, the default value is not the same.\n\nCURL >= 7.62.0: CURL_HTTP_VERSION_2TLS CURL < 7.62: CURL_HTTP_VERSION_1_1\n\nIn order to give users the freedom to control the HTTP version, we need to\nadd a setting to choose which HTTP version to use.\n\nThis patch support force enable HTTP/2 or HTTP/1.1. \n\nexample: \n\nGIT_CURL_VERBOSE=1 git2 -c http.version=HTTP/2 ls-remote https://bitbucket.org/aquariusjay/deeplab-public-ver2.git\n\nForce Charlie (1):\n  http: add support selecting http version\n\n Documentation/config.txt |  9 +++++++++\n http.c                   | 38 ++++++++++++++++++++++++++++++++++++++\n 2 files changed, 47 insertions(+)\n\n\nbase-commit: 8858448bb49332d353febc078ce4a3abcc962efe\nPublished-As: https://github.com/gitgitgadget/git/releases/tags/pr-69%2Ffcharlie%2Fmaster-v6\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-69/fcharlie/master-v6\nPull-Request: https://github.com/gitgitgadget/git/pull/69\n\nRange-diff vs v5:\n\n 1:  cdd93048ba ! 1:  93fda67198 http: add support selecting http version\n     @@ -2,8 +2,38 @@\n      \n          http: add support selecting http version\n      \n     +    Usually we don't need to set libcurl to choose which version of the\n     +    HTTP protocol to use to communicate with a server.\n     +    But different versions of libcurl, the default value is not the same.\n     +\n     +    CURL >= 7.62.0: CURL_HTTP_VERSION_2TLS\n     +    CURL < 7.62: CURL_HTTP_VERSION_1_1\n     +\n     +    In order to give users the freedom to control the HTTP version,\n     +    we need to add a setting to choose which HTTP version to use.\n     +\n          Signed-off-by: Force Charlie <charlieio@outlook.com>\n      \n     +diff --git a/Documentation/config.txt b/Documentation/config.txt\n     +--- a/Documentation/config.txt\n     ++++ b/Documentation/config.txt\n     +@@\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     ++\tUse the specified HTTP protocol version when communicating with a server.\n     ++\tIf you want to force the default. The available and default version depend\n     ++\ton libcurl. Actually the possible values of\n     ++\tthis option are:\n     ++\n     ++\t- HTTP/2\n     ++\t- HTTP/1.1\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\n     +\n      diff --git a/http.c b/http.c\n      --- a/http.c\n      +++ b/http.c\n\n-- \ngitgitgadget\n"},{"id":"362731","messageId":"93fda67198441c159bfcf1dfa467ad76f3ecba76.1541660405.git.gitgitgadget@gmail.com","threadId":"49777","inReplyTo":"pull.69.v6.git.gitgitgadget@gmail.com","subject":"[PATCH v6 1/1] http: add support selecting http version","fromName":"Force Charlie via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-08T07:00:08Z","receivedAt":"2018-11-08T07:00:11Z","isPatch":true,"sender":{"key":"name:Force Charlie","avatar":null},"body":"From: Force Charlie <charlieio@outlook.com>\n\nUsually we don't need to set libcurl to choose which version of the\nHTTP protocol to use to communicate with a server.\nBut different versions of libcurl, the default value is not the same.\n\nCURL >= 7.62.0: CURL_HTTP_VERSION_2TLS\nCURL < 7.62: CURL_HTTP_VERSION_1_1\n\nIn order to give users the freedom to control the HTTP version,\nwe need to add a setting to choose which HTTP version to use.\n\nSigned-off-by: Force Charlie <charlieio@outlook.com>\n---\n Documentation/config.txt |  9 +++++++++\n http.c                   | 38 ++++++++++++++++++++++++++++++++++++++\n 2 files changed, 47 insertions(+)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 41a9ff2b6a..f397942128 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1935,6 +1935,15 @@ 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+\tUse the specified HTTP protocol version when communicating with a server.\n+\tIf you want to force the default. The available and default version depend\n+\ton libcurl. Actually the possible values of\n+\tthis option are:\n+\n+\t- HTTP/2\n+\t- HTTP/1.1\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 a/http.c b/http.c\nindex 3dc8c560d6..d6f3c4ee80 100644\n--- a/http.c\n+++ b/http.c\n@@ -48,6 +48,7 @@ char curl_errorstr[CURL_ERROR_SIZE];\n \n static int curl_ssl_verify = -1;\n static int curl_ssl_try;\n+static const char *curl_http_version = NULL;\n static const char *ssl_cert;\n static const char *ssl_cipherlist;\n static const char *ssl_version;\n@@ -284,6 +285,9 @@ static void process_curl_messages(void)\n \n static int http_options(const char *var, const char *value, void *cb)\n {\n+\tif (!strcmp(\"http.version\",var)) {\n+\t\treturn git_config_string(&curl_http_version, var, value);\n+\t}\n \tif (!strcmp(\"http.sslverify\", var)) {\n \t\tcurl_ssl_verify = git_config_bool(var, value);\n \t\treturn 0;\n@@ -789,6 +793,30 @@ static long get_curl_allowed_protocols(int from_user)\n }\n #endif\n \n+#if LIBCURL_VERSION_NUM >=0x072f00\n+static int get_curl_http_version_opt(const char *version_string, long *opt)\n+{\n+\tint i;\n+\tstatic struct {\n+\t\tconst char *name;\n+\t\tlong opt_token;\n+\t} choice[] = {\n+\t\t{ \"HTTP/1.1\", CURL_HTTP_VERSION_1_1 },\n+\t\t{ \"HTTP/2\", CURL_HTTP_VERSION_2 }\n+\t};\n+\n+\tfor (i = 0; i < ARRAY_SIZE(choice); i++) {\n+\t\tif (!strcmp(version_string, choice[i].name)) {\n+\t\t\t*opt = choice[i].opt_token;\n+\t\t\treturn 0;\n+\t\t}\n+\t}\n+\n+\treturn -1; /* not found */\n+}\n+\n+#endif\n+\n static CURL *get_curl_handle(void)\n {\n \tCURL *result = curl_easy_init();\n@@ -806,6 +834,16 @@ static CURL *get_curl_handle(void)\n \t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);\n \t}\n \n+#if LIBCURL_VERSION_NUM >= 0x072f00 // 7.47.0\n+    if (curl_http_version) {\n+\t\tlong opt;\n+\t\tif (!get_curl_http_version_opt(curl_http_version, &opt)) {\n+\t\t\t/* Set request use http version */\n+\t\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,opt);\n+\t\t}\n+    }\n+#endif\n+\n #if LIBCURL_VERSION_NUM >= 0x070907\n \tcurl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);\n #endif\n-- \ngitgitgadget\n"},{"id":"362747","messageId":"CAPig+cRpH0k-qams+_1LK9p8hYzBhD-bG3waNLeCSzYWNY41rg@mail.gmail.com","threadId":"49777","inReplyTo":"93fda67198441c159bfcf1dfa467ad76f3ecba76.1541660405.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v6 1/1] http: add support selecting http version","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2018-11-08T18:02:04Z","receivedAt":"2018-11-08T18:02:17Z","isPatch":true,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Thu, Nov 8, 2018 at 2:00 AM Force Charlie via GitGitGadget\n<gitgitgadget@gmail.com> wrote:\n> In order to give users the freedom to control the HTTP version,\n> we need to add a setting to choose which HTTP version to use.\n>\n> Signed-off-by: Force Charlie <charlieio@outlook.com>\n> ---\n> diff --git a/http.c b/http.c\n> @@ -284,6 +285,9 @@ static void process_curl_messages(void)\n>  static int http_options(const char *var, const char *value, void *cb)\n>  {\n> +       if (!strcmp(\"http.version\",var)) {\n\nStyle: space after comma\n\n> +               return git_config_string(&curl_http_version, var, value);\n> +       }\n> @@ -806,6 +834,16 @@ static CURL *get_curl_handle(void)\n> +    if (curl_http_version) {\n> +               long opt;\n> +               if (!get_curl_http_version_opt(curl_http_version, &opt)) {\n> +                       /* Set request use http version */\n> +                       curl_easy_setopt(result, CURLOPT_HTTP_VERSION,opt);\n\nStyle: space after comma\n\n> +               }\n> +    }\n"},{"id":"362763","messageId":"pull.69.v7.git.gitgitgadget@gmail.com","threadId":"49777","inReplyTo":"pull.69.v6.git.gitgitgadget@gmail.com","subject":"[PATCH v7 0/1] http: add support selecting http version","fromName":"Force.Charlie-I via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-08T23:15:17Z","receivedAt":"2018-11-08T23:15:21Z","isPatch":true,"sender":{"key":"name:Force.Charlie-I","avatar":null},"body":"Usually we don't need to set libcurl to choose which version of the HTTP\nprotocol to use to communicate with a server. But different versions of\nlibcurl, the default value is not the same.\n\nCURL >= 7.62.0: CURL_HTTP_VERSION_2TLS CURL < 7.62: CURL_HTTP_VERSION_1_1\n\nIn order to give users the freedom to control the HTTP version, we need to\nadd a setting to choose which HTTP version to use.\n\nThis patch support force enable HTTP/2 or HTTP/1.1. \n\nexample: \n\nGIT_CURL_VERBOSE=1 git2 -c http.version=HTTP/2 ls-remote https://bitbucket.org/aquariusjay/deeplab-public-ver2.git\n\nForce Charlie (1):\n  http: add support selecting http version\n\n Documentation/config.txt |  9 +++++++++\n http.c                   | 38 ++++++++++++++++++++++++++++++++++++++\n 2 files changed, 47 insertions(+)\n\n\nbase-commit: 8858448bb49332d353febc078ce4a3abcc962efe\nPublished-As: https://github.com/gitgitgadget/git/releases/tags/pr-69%2Ffcharlie%2Fmaster-v7\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-69/fcharlie/master-v7\nPull-Request: https://github.com/gitgitgadget/git/pull/69\n\nRange-diff vs v6:\n\n 1:  93fda67198 ! 1:  e26fc0d8c7 http: add support selecting http version\n     @@ -49,7 +49,7 @@\n       \n       static int http_options(const char *var, const char *value, void *cb)\n       {\n     -+\tif (!strcmp(\"http.version\",var)) {\n     ++\tif (!strcmp(\"http.version\", var)) {\n      +\t\treturn git_config_string(&curl_http_version, var, value);\n      +\t}\n       \tif (!strcmp(\"http.sslverify\", var)) {\n     @@ -95,7 +95,7 @@\n      +\t\tlong opt;\n      +\t\tif (!get_curl_http_version_opt(curl_http_version, &opt)) {\n      +\t\t\t/* Set request use http version */\n     -+\t\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION,opt);\n     ++\t\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION, opt);\n      +\t\t}\n      +    }\n      +#endif\n\n-- \ngitgitgadget\n"},{"id":"362764","messageId":"e26fc0d8c77df749c14dd433a0ee66ed1bca17ef.1541718916.git.gitgitgadget@gmail.com","threadId":"49777","inReplyTo":"pull.69.v7.git.gitgitgadget@gmail.com","subject":"[PATCH v7 1/1] http: add support selecting http version","fromName":"Force Charlie via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-08T23:15:19Z","receivedAt":"2018-11-08T23:15:22Z","isPatch":true,"sender":{"key":"name:Force Charlie","avatar":null},"body":"From: Force Charlie <charlieio@outlook.com>\n\nUsually we don't need to set libcurl to choose which version of the\nHTTP protocol to use to communicate with a server.\nBut different versions of libcurl, the default value is not the same.\n\nCURL >= 7.62.0: CURL_HTTP_VERSION_2TLS\nCURL < 7.62: CURL_HTTP_VERSION_1_1\n\nIn order to give users the freedom to control the HTTP version,\nwe need to add a setting to choose which HTTP version to use.\n\nSigned-off-by: Force Charlie <charlieio@outlook.com>\n---\n Documentation/config.txt |  9 +++++++++\n http.c                   | 38 ++++++++++++++++++++++++++++++++++++++\n 2 files changed, 47 insertions(+)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 41a9ff2b6a..f397942128 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1935,6 +1935,15 @@ 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+\tUse the specified HTTP protocol version when communicating with a server.\n+\tIf you want to force the default. The available and default version depend\n+\ton libcurl. Actually the possible values of\n+\tthis option are:\n+\n+\t- HTTP/2\n+\t- HTTP/1.1\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 a/http.c b/http.c\nindex 3dc8c560d6..c22275bdee 100644\n--- a/http.c\n+++ b/http.c\n@@ -48,6 +48,7 @@ char curl_errorstr[CURL_ERROR_SIZE];\n \n static int curl_ssl_verify = -1;\n static int curl_ssl_try;\n+static const char *curl_http_version = NULL;\n static const char *ssl_cert;\n static const char *ssl_cipherlist;\n static const char *ssl_version;\n@@ -284,6 +285,9 @@ static void process_curl_messages(void)\n \n static int http_options(const char *var, const char *value, void *cb)\n {\n+\tif (!strcmp(\"http.version\", var)) {\n+\t\treturn git_config_string(&curl_http_version, var, value);\n+\t}\n \tif (!strcmp(\"http.sslverify\", var)) {\n \t\tcurl_ssl_verify = git_config_bool(var, value);\n \t\treturn 0;\n@@ -789,6 +793,30 @@ static long get_curl_allowed_protocols(int from_user)\n }\n #endif\n \n+#if LIBCURL_VERSION_NUM >=0x072f00\n+static int get_curl_http_version_opt(const char *version_string, long *opt)\n+{\n+\tint i;\n+\tstatic struct {\n+\t\tconst char *name;\n+\t\tlong opt_token;\n+\t} choice[] = {\n+\t\t{ \"HTTP/1.1\", CURL_HTTP_VERSION_1_1 },\n+\t\t{ \"HTTP/2\", CURL_HTTP_VERSION_2 }\n+\t};\n+\n+\tfor (i = 0; i < ARRAY_SIZE(choice); i++) {\n+\t\tif (!strcmp(version_string, choice[i].name)) {\n+\t\t\t*opt = choice[i].opt_token;\n+\t\t\treturn 0;\n+\t\t}\n+\t}\n+\n+\treturn -1; /* not found */\n+}\n+\n+#endif\n+\n static CURL *get_curl_handle(void)\n {\n \tCURL *result = curl_easy_init();\n@@ -806,6 +834,16 @@ static CURL *get_curl_handle(void)\n \t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);\n \t}\n \n+#if LIBCURL_VERSION_NUM >= 0x072f00 // 7.47.0\n+    if (curl_http_version) {\n+\t\tlong opt;\n+\t\tif (!get_curl_http_version_opt(curl_http_version, &opt)) {\n+\t\t\t/* Set request use http version */\n+\t\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION, opt);\n+\t\t}\n+    }\n+#endif\n+\n #if LIBCURL_VERSION_NUM >= 0x070907\n \tcurl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);\n #endif\n-- \ngitgitgadget\n"},{"id":"362768","messageId":"xmqqzhuj5574.fsf@gitster-ct.c.googlers.com","threadId":"49777","inReplyTo":"93fda67198441c159bfcf1dfa467ad76f3ecba76.1541660405.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v6 1/1] http: add support selecting http version","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-11-09T02:56:47Z","receivedAt":"2018-11-09T02:56:53Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Force Charlie via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> +#if LIBCURL_VERSION_NUM >=0x072f00\n> +static int get_curl_http_version_opt(const char *version_string, long *opt)\n> +{\n> +\tint i;\n> +\tstatic struct {\n> +\t\tconst char *name;\n> +\t\tlong opt_token;\n> +\t} choice[] = {\n> +\t\t{ \"HTTP/1.1\", CURL_HTTP_VERSION_1_1 },\n> +\t\t{ \"HTTP/2\", CURL_HTTP_VERSION_2 }\n> +\t};\n> +\n> +\tfor (i = 0; i < ARRAY_SIZE(choice); i++) {\n> +\t\tif (!strcmp(version_string, choice[i].name)) {\n> +\t\t\t*opt = choice[i].opt_token;\n> +\t\t\treturn 0;\n> +\t\t}\n> +\t}\n> +\n\nI wonder if we need to give a warning here about an unknown and\nignored value, by calling something like\n\n\twarning(\"unknown value given to http.version: '%s'\", version_string);\n\nhere.  We should not trigger noisy warning while reading the\nconfiguration file looking for other variables unrelated to\nhttp.version but this codepath is followed only when we know\nwe need to find out what value the variable is set to, so it\nprobably is a good thing to do.  \n\nThoughts?\n\n"},{"id":"362769","messageId":"xmqqva57556d.fsf@gitster-ct.c.googlers.com","threadId":"49777","inReplyTo":"CAPig+cRpH0k-qams+_1LK9p8hYzBhD-bG3waNLeCSzYWNY41rg@mail.gmail.com","subject":"Re: [PATCH v6 1/1] http: add support selecting http version","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-11-09T02:57:14Z","receivedAt":"2018-11-09T02:57:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Sunshine <sunshine@sunshineco.com> writes:\n\n>> @@ -284,6 +285,9 @@ static void process_curl_messages(void)\n>>  static int http_options(const char *var, const char *value, void *cb)\n>>  {\n>> +       if (!strcmp(\"http.version\",var)) {\n>\n> Style: space after comma\n>\n>> +               return git_config_string(&curl_http_version, var, value);\n>> +       }\n>> @@ -806,6 +834,16 @@ static CURL *get_curl_handle(void)\n>> +    if (curl_http_version) {\n>> +               long opt;\n>> +               if (!get_curl_http_version_opt(curl_http_version, &opt)) {\n>> +                       /* Set request use http version */\n>> +                       curl_easy_setopt(result, CURLOPT_HTTP_VERSION,opt);\n>\n> Style: space after comma\n>\n>> +               }\n>> +    }\n\nThanks, both.  This is almost done, I think.\n"},{"id":"362772","messageId":"pull.69.v8.git.gitgitgadget@gmail.com","threadId":"49777","inReplyTo":"pull.69.v7.git.gitgitgadget@gmail.com","subject":"[PATCH v8 0/1] http: add support selecting http version","fromName":"Force.Charlie-I via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-09T03:44:13Z","receivedAt":"2018-11-09T03:44:16Z","isPatch":true,"sender":{"key":"name:Force.Charlie-I","avatar":null},"body":"Usually we don't need to set libcurl to choose which version of the HTTP\nprotocol to use to communicate with a server. But different versions of\nlibcurl, the default value is not the same.\n\nCURL >= 7.62.0: CURL_HTTP_VERSION_2TLS CURL < 7.62: CURL_HTTP_VERSION_1_1\n\nIn order to give users the freedom to control the HTTP version, we need to\nadd a setting to choose which HTTP version to use.\n\nThis patch support force enable HTTP/2 or HTTP/1.1. \n\nexample: \n\nGIT_CURL_VERBOSE=1 git2 -c http.version=HTTP/2 ls-remote https://bitbucket.org/aquariusjay/deeplab-public-ver2.git\n\nForce Charlie (1):\n  http: add support selecting http version\n\n Documentation/config.txt |  9 +++++++++\n http.c                   | 39 +++++++++++++++++++++++++++++++++++++++\n 2 files changed, 48 insertions(+)\n\n\nbase-commit: 8858448bb49332d353febc078ce4a3abcc962efe\nPublished-As: https://github.com/gitgitgadget/git/releases/tags/pr-69%2Ffcharlie%2Fmaster-v8\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-69/fcharlie/master-v8\nPull-Request: https://github.com/gitgitgadget/git/pull/69\n\nRange-diff vs v7:\n\n 1:  e26fc0d8c7 ! 1:  71f8b71b34 http: add support selecting http version\n     @@ -78,6 +78,7 @@\n      +\t\t}\n      +\t}\n      +\n     ++\twarning(\"unknown value given to http.version: '%s'\", version_string);\n      +\treturn -1; /* not found */\n      +}\n      +\n\n-- \ngitgitgadget\n"},{"id":"362773","messageId":"71f8b71b346f132d0dc9a23c9a7f2ca2cb91966f.1541735051.git.gitgitgadget@gmail.com","threadId":"49777","inReplyTo":"pull.69.v8.git.gitgitgadget@gmail.com","subject":"[PATCH v8 1/1] http: add support selecting http version","fromName":"Force Charlie via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2018-11-09T03:44:14Z","receivedAt":"2018-11-09T03:44:18Z","isPatch":true,"sender":{"key":"name:Force Charlie","avatar":null},"body":"From: Force Charlie <charlieio@outlook.com>\n\nUsually we don't need to set libcurl to choose which version of the\nHTTP protocol to use to communicate with a server.\nBut different versions of libcurl, the default value is not the same.\n\nCURL >= 7.62.0: CURL_HTTP_VERSION_2TLS\nCURL < 7.62: CURL_HTTP_VERSION_1_1\n\nIn order to give users the freedom to control the HTTP version,\nwe need to add a setting to choose which HTTP version to use.\n\nSigned-off-by: Force Charlie <charlieio@outlook.com>\n---\n Documentation/config.txt |  9 +++++++++\n http.c                   | 39 +++++++++++++++++++++++++++++++++++++++\n 2 files changed, 48 insertions(+)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 41a9ff2b6a..f397942128 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -1935,6 +1935,15 @@ 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+\tUse the specified HTTP protocol version when communicating with a server.\n+\tIf you want to force the default. The available and default version depend\n+\ton libcurl. Actually the possible values of\n+\tthis option are:\n+\n+\t- HTTP/2\n+\t- HTTP/1.1\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 a/http.c b/http.c\nindex 3dc8c560d6..bc3274804e 100644\n--- a/http.c\n+++ b/http.c\n@@ -48,6 +48,7 @@ char curl_errorstr[CURL_ERROR_SIZE];\n \n static int curl_ssl_verify = -1;\n static int curl_ssl_try;\n+static const char *curl_http_version = NULL;\n static const char *ssl_cert;\n static const char *ssl_cipherlist;\n static const char *ssl_version;\n@@ -284,6 +285,9 @@ static void process_curl_messages(void)\n \n static int http_options(const char *var, const char *value, void *cb)\n {\n+\tif (!strcmp(\"http.version\", var)) {\n+\t\treturn git_config_string(&curl_http_version, var, value);\n+\t}\n \tif (!strcmp(\"http.sslverify\", var)) {\n \t\tcurl_ssl_verify = git_config_bool(var, value);\n \t\treturn 0;\n@@ -789,6 +793,31 @@ static long get_curl_allowed_protocols(int from_user)\n }\n #endif\n \n+#if LIBCURL_VERSION_NUM >=0x072f00\n+static int get_curl_http_version_opt(const char *version_string, long *opt)\n+{\n+\tint i;\n+\tstatic struct {\n+\t\tconst char *name;\n+\t\tlong opt_token;\n+\t} choice[] = {\n+\t\t{ \"HTTP/1.1\", CURL_HTTP_VERSION_1_1 },\n+\t\t{ \"HTTP/2\", CURL_HTTP_VERSION_2 }\n+\t};\n+\n+\tfor (i = 0; i < ARRAY_SIZE(choice); i++) {\n+\t\tif (!strcmp(version_string, choice[i].name)) {\n+\t\t\t*opt = choice[i].opt_token;\n+\t\t\treturn 0;\n+\t\t}\n+\t}\n+\n+\twarning(\"unknown value given to http.version: '%s'\", version_string);\n+\treturn -1; /* not found */\n+}\n+\n+#endif\n+\n static CURL *get_curl_handle(void)\n {\n \tCURL *result = curl_easy_init();\n@@ -806,6 +835,16 @@ static CURL *get_curl_handle(void)\n \t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);\n \t}\n \n+#if LIBCURL_VERSION_NUM >= 0x072f00 // 7.47.0\n+    if (curl_http_version) {\n+\t\tlong opt;\n+\t\tif (!get_curl_http_version_opt(curl_http_version, &opt)) {\n+\t\t\t/* Set request use http version */\n+\t\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION, opt);\n+\t\t}\n+    }\n+#endif\n+\n #if LIBCURL_VERSION_NUM >= 0x070907\n \tcurl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);\n #endif\n-- \ngitgitgadget\n"},{"id":"362774","messageId":"xmqqefbu6h7g.fsf@gitster-ct.c.googlers.com","threadId":"49777","inReplyTo":"e26fc0d8c77df749c14dd433a0ee66ed1bca17ef.1541718916.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v7 1/1] http: add support selecting http version","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2018-11-09T03:52:03Z","receivedAt":"2018-11-09T03:52:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Force Charlie via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> +http.version::\n> +\tUse the specified HTTP protocol version when communicating with a server.\n> +\tIf you want to force the default. The available and default version depend\n> +\ton libcurl. Actually the possible values of\n> +\tthis option are:\n> +\n> +\t- HTTP/2\n> +\t- HTTP/1.1\n> +\n\nI just wanted to make sure this formats well; it uses the same\nconstruct as used to make the list of allowed values for the next\nentry (sslVersion), so this should be fine.\n\nThanks.\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\n> diff --git a/http.c b/http.c\n> index 3dc8c560d6..c22275bdee 100644\n> --- a/http.c\n> +++ b/http.c\n> @@ -48,6 +48,7 @@ char curl_errorstr[CURL_ERROR_SIZE];\n>  \n>  static int curl_ssl_verify = -1;\n>  static int curl_ssl_try;\n> +static const char *curl_http_version = NULL;\n>  static const char *ssl_cert;\n>  static const char *ssl_cipherlist;\n>  static const char *ssl_version;\n> @@ -284,6 +285,9 @@ static void process_curl_messages(void)\n>  \n>  static int http_options(const char *var, const char *value, void *cb)\n>  {\n> +\tif (!strcmp(\"http.version\", var)) {\n> +\t\treturn git_config_string(&curl_http_version, var, value);\n> +\t}\n>  \tif (!strcmp(\"http.sslverify\", var)) {\n>  \t\tcurl_ssl_verify = git_config_bool(var, value);\n>  \t\treturn 0;\n> @@ -789,6 +793,30 @@ static long get_curl_allowed_protocols(int from_user)\n>  }\n>  #endif\n>  \n> +#if LIBCURL_VERSION_NUM >=0x072f00\n> +static int get_curl_http_version_opt(const char *version_string, long *opt)\n> +{\n> +\tint i;\n> +\tstatic struct {\n> +\t\tconst char *name;\n> +\t\tlong opt_token;\n> +\t} choice[] = {\n> +\t\t{ \"HTTP/1.1\", CURL_HTTP_VERSION_1_1 },\n> +\t\t{ \"HTTP/2\", CURL_HTTP_VERSION_2 }\n> +\t};\n> +\n> +\tfor (i = 0; i < ARRAY_SIZE(choice); i++) {\n> +\t\tif (!strcmp(version_string, choice[i].name)) {\n> +\t\t\t*opt = choice[i].opt_token;\n> +\t\t\treturn 0;\n> +\t\t}\n> +\t}\n> +\n> +\treturn -1; /* not found */\n> +}\n> +\n> +#endif\n> +\n>  static CURL *get_curl_handle(void)\n>  {\n>  \tCURL *result = curl_easy_init();\n> @@ -806,6 +834,16 @@ static CURL *get_curl_handle(void)\n>  \t\tcurl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);\n>  \t}\n>  \n> +#if LIBCURL_VERSION_NUM >= 0x072f00 // 7.47.0\n> +    if (curl_http_version) {\n> +\t\tlong opt;\n> +\t\tif (!get_curl_http_version_opt(curl_http_version, &opt)) {\n> +\t\t\t/* Set request use http version */\n> +\t\t\tcurl_easy_setopt(result, CURLOPT_HTTP_VERSION, opt);\n> +\t\t}\n> +    }\n> +#endif\n> +\n>  #if LIBCURL_VERSION_NUM >= 0x070907\n>  \tcurl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);\n>  #endif\n"}]}