* [PATCH v4 1/4] http: add support selecting http version
2018-11-08 6:14 ` [PATCH v4 0/4] http: add support selecting http version Force.Charlie-I via GitGitGadget
@ 2018-11-08 6:14 ` Force Charlie via GitGitGadget
2018-11-08 6:14 ` [PATCH v4 2/4] support force use http 1.1 Force Charlie via GitGitGadget
` (3 subsequent siblings)
4 siblings, 0 replies; 33+ messages in thread
From: Force Charlie via GitGitGadget @ 2018-11-08 6:14 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Force Charlie
From: Force Charlie <charlieio@outlook.com>
Signed-off-by: Force Charlie <charlieio@outlook.com>
---
http.c | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/http.c b/http.c
index 3dc8c560d6..99cb04faba 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 int curl_http_version = 11;
static const char *ssl_cert;
static const char *ssl_cipherlist;
static const char *ssl_version;
@@ -284,6 +285,10 @@ static void process_curl_messages(void)
static int http_options(const char *var, const char *value, void *cb)
{
+ if (!strcmp("http.version",var)) {
+ curl_http_version=git_config_int(var,value);
+ return 0;
+ }
if (!strcmp("http.sslverify", var)) {
curl_ssl_verify = git_config_bool(var, value);
return 0;
@@ -806,6 +811,13 @@ static CURL *get_curl_handle(void)
curl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);
}
+#if LIBCURL_VERSION_NUM >= 0x073100
+ if(curl_http_version == 20){
+ /* CURL Enable HTTP2*/
+ curl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2);
+ }
+#endif
+
#if LIBCURL_VERSION_NUM >= 0x070907
curl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
#endif
--
gitgitgadget
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v4 2/4] support force use http 1.1
2018-11-08 6:14 ` [PATCH v4 0/4] http: add support selecting http version Force.Charlie-I via GitGitGadget
2018-11-08 6:14 ` [PATCH v4 1/4] " Force Charlie via GitGitGadget
@ 2018-11-08 6:14 ` Force Charlie via GitGitGadget
2018-11-08 6:14 ` [PATCH v4 3/4] fix curl version to support CURL_HTTP_VERSION_2TLS Force Charlie via GitGitGadget
` (2 subsequent siblings)
4 siblings, 0 replies; 33+ messages in thread
From: Force Charlie via GitGitGadget @ 2018-11-08 6:14 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Force Charlie
From: Force Charlie <charlieio@outlook.com>
Signed-off-by: Force Charlie <charlieio@outlook.com>
---
http.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/http.c b/http.c
index 99cb04faba..b2ec31aef5 100644
--- a/http.c
+++ b/http.c
@@ -48,7 +48,7 @@ char curl_errorstr[CURL_ERROR_SIZE];
static int curl_ssl_verify = -1;
static int curl_ssl_try;
-static int curl_http_version = 11;
+static int curl_http_version = 0;
static const char *ssl_cert;
static const char *ssl_cipherlist;
static const char *ssl_version;
@@ -811,11 +811,14 @@ static CURL *get_curl_handle(void)
curl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);
}
-#if LIBCURL_VERSION_NUM >= 0x073100
- if(curl_http_version == 20){
- /* CURL Enable HTTP2*/
- curl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2);
- }
+#if LIBCURL_VERSION_NUM >= 0x074700
+ // curl_http_version 0 is default.
+ if (curl_http_version == 20) {
+ /* Enable HTTP2 when request TLS*/
+ curl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2TLS);
+ } else if (curl_http_version == 11) {
+ curl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1);
+ }
#endif
#if LIBCURL_VERSION_NUM >= 0x070907
--
gitgitgadget
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v4 3/4] fix curl version to support CURL_HTTP_VERSION_2TLS
2018-11-08 6:14 ` [PATCH v4 0/4] http: add support selecting http version Force.Charlie-I via GitGitGadget
2018-11-08 6:14 ` [PATCH v4 1/4] " Force Charlie via GitGitGadget
2018-11-08 6:14 ` [PATCH v4 2/4] support force use http 1.1 Force Charlie via GitGitGadget
@ 2018-11-08 6:14 ` Force Charlie via GitGitGadget
2018-11-08 6:14 ` [PATCH v4 4/4] http: change http.version value type Force Charlie via GitGitGadget
2018-11-08 6:18 ` [PATCH v5 0/1] http: add support selecting http version Force.Charlie-I via GitGitGadget
4 siblings, 0 replies; 33+ messages in thread
From: Force Charlie via GitGitGadget @ 2018-11-08 6:14 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Force Charlie
From: Force Charlie <charlieio@outlook.com>
Signed-off-by: Force Charlie <charlieio@outlook.com>
---
http.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/http.c b/http.c
index b2ec31aef5..86e454cff5 100644
--- a/http.c
+++ b/http.c
@@ -811,10 +811,10 @@ static CURL *get_curl_handle(void)
curl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);
}
-#if LIBCURL_VERSION_NUM >= 0x074700
+#if LIBCURL_VERSION_NUM >= 0x072f00 // 7.47.0
// curl_http_version 0 is default.
if (curl_http_version == 20) {
- /* Enable HTTP2 when request TLS*/
+ /* Enable HTTP2*/
curl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2TLS);
} else if (curl_http_version == 11) {
curl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1);
--
gitgitgadget
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v4 4/4] http: change http.version value type
2018-11-08 6:14 ` [PATCH v4 0/4] http: add support selecting http version Force.Charlie-I via GitGitGadget
` (2 preceding siblings ...)
2018-11-08 6:14 ` [PATCH v4 3/4] fix curl version to support CURL_HTTP_VERSION_2TLS Force Charlie via GitGitGadget
@ 2018-11-08 6:14 ` Force Charlie via GitGitGadget
2018-11-08 6:18 ` [PATCH v5 0/1] http: add support selecting http version Force.Charlie-I via GitGitGadget
4 siblings, 0 replies; 33+ messages in thread
From: Force Charlie via GitGitGadget @ 2018-11-08 6:14 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Force Charlie
From: Force Charlie <charlieio@outlook.com>
Signed-off-by: Force Charlie <charlieio@outlook.com>
---
http.c | 41 ++++++++++++++++++++++++++++++++---------
1 file changed, 32 insertions(+), 9 deletions(-)
diff --git a/http.c b/http.c
index 86e454cff5..d6f3c4ee80 100644
--- a/http.c
+++ b/http.c
@@ -48,7 +48,7 @@ char curl_errorstr[CURL_ERROR_SIZE];
static int curl_ssl_verify = -1;
static int curl_ssl_try;
-static int curl_http_version = 0;
+static const char *curl_http_version = NULL;
static const char *ssl_cert;
static const char *ssl_cipherlist;
static const char *ssl_version;
@@ -286,8 +286,7 @@ static void process_curl_messages(void)
static int http_options(const char *var, const char *value, void *cb)
{
if (!strcmp("http.version",var)) {
- curl_http_version=git_config_int(var,value);
- return 0;
+ return git_config_string(&curl_http_version, var, value);
}
if (!strcmp("http.sslverify", var)) {
curl_ssl_verify = git_config_bool(var, value);
@@ -794,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();
@@ -812,12 +835,12 @@ static CURL *get_curl_handle(void)
}
#if LIBCURL_VERSION_NUM >= 0x072f00 // 7.47.0
- // curl_http_version 0 is default.
- if (curl_http_version == 20) {
- /* Enable HTTP2*/
- curl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2TLS);
- } else if (curl_http_version == 11) {
- curl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1);
+ if (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
--
gitgitgadget
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v5 0/1] http: add support selecting http version
2018-11-08 6:14 ` [PATCH v4 0/4] http: add support selecting http version Force.Charlie-I via GitGitGadget
` (3 preceding siblings ...)
2018-11-08 6:14 ` [PATCH v4 4/4] http: change http.version value type Force Charlie via GitGitGadget
@ 2018-11-08 6:18 ` Force.Charlie-I via GitGitGadget
2018-11-08 6:18 ` [PATCH v5 1/1] " Force Charlie via GitGitGadget
2018-11-08 7:00 ` [PATCH v6 0/1] " Force.Charlie-I via GitGitGadget
4 siblings, 2 replies; 33+ messages in thread
From: Force.Charlie-I via GitGitGadget @ 2018-11-08 6:18 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
Normally, git doesn't need to set curl to select the HTTP version, it works
fine without HTTP/2. Adding HTTP/2 support is a icing on the cake.
This patch support force enable HTTP/2 or HTTP/1.1.
example:
GIT_CURL_VERBOSE=1 git2 -c http.version=HTTP/2 ls-remote https://bitbucket.org/aquariusjay/deeplab-public-ver2.git
Force Charlie (1):
http: add support selecting http version
http.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
base-commit: 8858448bb49332d353febc078ce4a3abcc962efe
Published-As: https://github.com/gitgitgadget/git/releases/tags/pr-69%2Ffcharlie%2Fmaster-v5
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-69/fcharlie/master-v5
Pull-Request: https://github.com/gitgitgadget/git/pull/69
Range-diff vs v4:
1: 4f5a935c43 < -: ---------- http: add support selecting http version
2: 06e9685d2b < -: ---------- support force use http 1.1
3: eee67d8356 < -: ---------- fix curl version to support CURL_HTTP_VERSION_2TLS
4: 0a7794722b ! 1: cdd93048ba http: change http.version value type
@@ -1,6 +1,6 @@
Author: Force Charlie <charlieio@outlook.com>
- http: change http.version value type
+ http: add support selecting http version
Signed-off-by: Force Charlie <charlieio@outlook.com>
@@ -11,21 +11,20 @@
static int curl_ssl_verify = -1;
static int curl_ssl_try;
--static int curl_http_version = 0;
+static const char *curl_http_version = NULL;
static const char *ssl_cert;
static const char *ssl_cipherlist;
static const char *ssl_version;
@@
+
static int http_options(const char *var, const char *value, void *cb)
{
- if (!strcmp("http.version",var)) {
-- curl_http_version=git_config_int(var,value);
-- return 0;
++ if (!strcmp("http.version",var)) {
+ return git_config_string(&curl_http_version, var, value);
- }
++ }
if (!strcmp("http.sslverify", var)) {
curl_ssl_verify = git_config_bool(var, value);
+ return 0;
@@
}
#endif
@@ -58,21 +57,19 @@
{
CURL *result = curl_easy_init();
@@
+ curl_easy_setopt(result, CURLOPT_SSL_VERIFYHOST, 2);
}
- #if LIBCURL_VERSION_NUM >= 0x072f00 // 7.47.0
-- // curl_http_version 0 is default.
-- if (curl_http_version == 20) {
-- /* Enable HTTP2*/
-- curl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2TLS);
-- } else if (curl_http_version == 11) {
-- curl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_1_1);
++#if LIBCURL_VERSION_NUM >= 0x072f00 // 7.47.0
+ if (curl_http_version) {
+ long opt;
+ if (!get_curl_http_version_opt(curl_http_version, &opt)) {
+ /* Set request use http version */
+ curl_easy_setopt(result, CURLOPT_HTTP_VERSION,opt);
+ }
- }
++ }
++#endif
++
+ #if LIBCURL_VERSION_NUM >= 0x070907
+ curl_easy_setopt(result, CURLOPT_NETRC, CURL_NETRC_OPTIONAL);
#endif
-
--
gitgitgadget
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v5 1/1] http: add support selecting http version
2018-11-08 6:18 ` [PATCH v5 0/1] http: add support selecting http version Force.Charlie-I via GitGitGadget
@ 2018-11-08 6:18 ` Force Charlie via GitGitGadget
2018-11-08 7:00 ` [PATCH v6 0/1] " Force.Charlie-I via GitGitGadget
1 sibling, 0 replies; 33+ messages in thread
From: Force Charlie via GitGitGadget @ 2018-11-08 6:18 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Force Charlie
From: Force Charlie <charlieio@outlook.com>
Signed-off-by: Force Charlie <charlieio@outlook.com>
---
http.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/http.c b/http.c
index 3dc8c560d6..d6f3c4ee80 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
--
gitgitgadget
^ permalink raw reply related [flat|nested] 33+ messages in thread
* [PATCH v6 0/1] http: add support selecting http version
2018-11-08 6:18 ` [PATCH v5 0/1] http: add support selecting http version Force.Charlie-I via GitGitGadget
2018-11-08 6:18 ` [PATCH v5 1/1] " Force Charlie via GitGitGadget
@ 2018-11-08 7:00 ` Force.Charlie-I via GitGitGadget
2018-11-08 7:00 ` [PATCH v6 1/1] " Force Charlie via GitGitGadget
2018-11-08 23:15 ` [PATCH v7 0/1] " Force.Charlie-I via GitGitGadget
1 sibling, 2 replies; 33+ messages in thread
From: Force.Charlie-I via GitGitGadget @ 2018-11-08 7:00 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
Usually we don't need to set libcurl to choose which version of the HTTP
protocol to use to communicate with a server. But different versions of
libcurl, the default value is not the same.
CURL >= 7.62.0: CURL_HTTP_VERSION_2TLS CURL < 7.62: CURL_HTTP_VERSION_1_1
In order to give users the freedom to control the HTTP version, we need to
add a setting to choose which HTTP version to use.
This patch support force enable HTTP/2 or HTTP/1.1.
example:
GIT_CURL_VERBOSE=1 git2 -c http.version=HTTP/2 ls-remote https://bitbucket.org/aquariusjay/deeplab-public-ver2.git
Force Charlie (1):
http: add support selecting http version
Documentation/config.txt | 9 +++++++++
http.c | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+)
base-commit: 8858448bb49332d353febc078ce4a3abcc962efe
Published-As: https://github.com/gitgitgadget/git/releases/tags/pr-69%2Ffcharlie%2Fmaster-v6
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-69/fcharlie/master-v6
Pull-Request: https://github.com/gitgitgadget/git/pull/69
Range-diff vs v5:
1: cdd93048ba ! 1: 93fda67198 http: add support selecting http version
@@ -2,8 +2,38 @@
http: add support selecting http version
+ Usually we don't need to set libcurl to choose which version of the
+ HTTP protocol to use to communicate with a server.
+ But different versions of libcurl, the default value is not the same.
+
+ CURL >= 7.62.0: CURL_HTTP_VERSION_2TLS
+ CURL < 7.62: CURL_HTTP_VERSION_1_1
+
+ In order to give users the freedom to control the HTTP version,
+ we need to add a setting to choose which HTTP version to use.
+
Signed-off-by: Force Charlie <charlieio@outlook.com>
+diff --git a/Documentation/config.txt b/Documentation/config.txt
+--- a/Documentation/config.txt
++++ b/Documentation/config.txt
+@@
+ If set, store cookies received during requests to the file specified by
+ http.cookieFile. Has no effect if http.cookieFile is unset.
+
++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
++
+ 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
--- a/http.c
+++ b/http.c
--
gitgitgadget
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v6 1/1] http: add support selecting http version
2018-11-08 7:00 ` [PATCH v6 0/1] " Force.Charlie-I via GitGitGadget
@ 2018-11-08 7:00 ` Force Charlie via GitGitGadget
2018-11-08 18:02 ` Eric Sunshine
2018-11-09 2:56 ` Junio C Hamano
2018-11-08 23:15 ` [PATCH v7 0/1] " Force.Charlie-I via GitGitGadget
1 sibling, 2 replies; 33+ messages in thread
From: Force Charlie via GitGitGadget @ 2018-11-08 7:00 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Force Charlie
From: Force Charlie <charlieio@outlook.com>
Usually we don't need to set libcurl to choose which version of the
HTTP protocol to use to communicate with a server.
But different versions of libcurl, the default value is not the same.
CURL >= 7.62.0: CURL_HTTP_VERSION_2TLS
CURL < 7.62: CURL_HTTP_VERSION_1_1
In order to give users the freedom to control the HTTP version,
we need to add a setting to choose which HTTP version to use.
Signed-off-by: Force Charlie <charlieio@outlook.com>
---
Documentation/config.txt | 9 +++++++++
http.c | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 41a9ff2b6a..f397942128 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1935,6 +1935,15 @@ 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::
+ 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
+
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..d6f3c4ee80 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
--
gitgitgadget
^ permalink raw reply related [flat|nested] 33+ messages in thread
* Re: [PATCH v6 1/1] http: add support selecting http version
2018-11-08 7:00 ` [PATCH v6 1/1] " Force Charlie via GitGitGadget
@ 2018-11-08 18:02 ` Eric Sunshine
2018-11-09 2:57 ` Junio C Hamano
2018-11-09 2:56 ` Junio C Hamano
1 sibling, 1 reply; 33+ messages in thread
From: Eric Sunshine @ 2018-11-08 18:02 UTC (permalink / raw)
To: gitgitgadget; +Cc: Git List, Junio C Hamano, charlieio
On Thu, Nov 8, 2018 at 2:00 AM Force Charlie via GitGitGadget
<gitgitgadget@gmail.com> wrote:
> In order to give users the freedom to control the HTTP version,
> we need to add a setting to choose which HTTP version to use.
>
> Signed-off-by: Force Charlie <charlieio@outlook.com>
> ---
> diff --git a/http.c b/http.c
> @@ -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)) {
Style: space after comma
> + return git_config_string(&curl_http_version, var, value);
> + }
> @@ -806,6 +834,16 @@ static CURL *get_curl_handle(void)
> + 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);
Style: space after comma
> + }
> + }
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v6 1/1] http: add support selecting http version
2018-11-08 18:02 ` Eric Sunshine
@ 2018-11-09 2:57 ` Junio C Hamano
0 siblings, 0 replies; 33+ messages in thread
From: Junio C Hamano @ 2018-11-09 2:57 UTC (permalink / raw)
To: Eric Sunshine; +Cc: gitgitgadget, Git List, charlieio
Eric Sunshine <sunshine@sunshineco.com> writes:
>> @@ -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)) {
>
> Style: space after comma
>
>> + return git_config_string(&curl_http_version, var, value);
>> + }
>> @@ -806,6 +834,16 @@ static CURL *get_curl_handle(void)
>> + 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);
>
> Style: space after comma
>
>> + }
>> + }
Thanks, both. This is almost done, I think.
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH v6 1/1] http: add support selecting http version
2018-11-08 7:00 ` [PATCH v6 1/1] " Force Charlie via GitGitGadget
2018-11-08 18:02 ` Eric Sunshine
@ 2018-11-09 2:56 ` Junio C Hamano
1 sibling, 0 replies; 33+ messages in thread
From: Junio C Hamano @ 2018-11-09 2:56 UTC (permalink / raw)
To: Force Charlie via GitGitGadget; +Cc: git, Force Charlie, Eric Sunshine
"Force Charlie via GitGitGadget" <gitgitgadget@gmail.com> writes:
> +#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;
> + }
> + }
> +
I wonder if we need to give a warning here about an unknown and
ignored value, by calling something like
warning("unknown value given to http.version: '%s'", version_string);
here. We should not trigger noisy warning while reading the
configuration file looking for other variables unrelated to
http.version but this codepath is followed only when we know
we need to find out what value the variable is set to, so it
probably is a good thing to do.
Thoughts?
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v7 0/1] http: add support selecting http version
2018-11-08 7:00 ` [PATCH v6 0/1] " Force.Charlie-I via GitGitGadget
2018-11-08 7:00 ` [PATCH v6 1/1] " Force Charlie via GitGitGadget
@ 2018-11-08 23:15 ` Force.Charlie-I via GitGitGadget
2018-11-08 23:15 ` [PATCH v7 1/1] " Force Charlie via GitGitGadget
2018-11-09 3:44 ` [PATCH v8 0/1] " Force.Charlie-I via GitGitGadget
1 sibling, 2 replies; 33+ messages in thread
From: Force.Charlie-I via GitGitGadget @ 2018-11-08 23:15 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
Usually we don't need to set libcurl to choose which version of the HTTP
protocol to use to communicate with a server. But different versions of
libcurl, the default value is not the same.
CURL >= 7.62.0: CURL_HTTP_VERSION_2TLS CURL < 7.62: CURL_HTTP_VERSION_1_1
In order to give users the freedom to control the HTTP version, we need to
add a setting to choose which HTTP version to use.
This patch support force enable HTTP/2 or HTTP/1.1.
example:
GIT_CURL_VERBOSE=1 git2 -c http.version=HTTP/2 ls-remote https://bitbucket.org/aquariusjay/deeplab-public-ver2.git
Force Charlie (1):
http: add support selecting http version
Documentation/config.txt | 9 +++++++++
http.c | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+)
base-commit: 8858448bb49332d353febc078ce4a3abcc962efe
Published-As: https://github.com/gitgitgadget/git/releases/tags/pr-69%2Ffcharlie%2Fmaster-v7
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-69/fcharlie/master-v7
Pull-Request: https://github.com/gitgitgadget/git/pull/69
Range-diff vs v6:
1: 93fda67198 ! 1: e26fc0d8c7 http: add support selecting http version
@@ -49,7 +49,7 @@
static int http_options(const char *var, const char *value, void *cb)
{
-+ if (!strcmp("http.version",var)) {
++ if (!strcmp("http.version", var)) {
+ return git_config_string(&curl_http_version, var, value);
+ }
if (!strcmp("http.sslverify", var)) {
@@ -95,7 +95,7 @@
+ 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);
++ curl_easy_setopt(result, CURLOPT_HTTP_VERSION, opt);
+ }
+ }
+#endif
--
gitgitgadget
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v7 1/1] http: add support selecting http version
2018-11-08 23:15 ` [PATCH v7 0/1] " Force.Charlie-I via GitGitGadget
@ 2018-11-08 23:15 ` Force Charlie via GitGitGadget
2018-11-09 3:52 ` Junio C Hamano
2018-11-09 3:44 ` [PATCH v8 0/1] " Force.Charlie-I via GitGitGadget
1 sibling, 1 reply; 33+ messages in thread
From: Force Charlie via GitGitGadget @ 2018-11-08 23:15 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Force Charlie
From: Force Charlie <charlieio@outlook.com>
Usually we don't need to set libcurl to choose which version of the
HTTP protocol to use to communicate with a server.
But different versions of libcurl, the default value is not the same.
CURL >= 7.62.0: CURL_HTTP_VERSION_2TLS
CURL < 7.62: CURL_HTTP_VERSION_1_1
In order to give users the freedom to control the HTTP version,
we need to add a setting to choose which HTTP version to use.
Signed-off-by: Force Charlie <charlieio@outlook.com>
---
Documentation/config.txt | 9 +++++++++
http.c | 38 ++++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 41a9ff2b6a..f397942128 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1935,6 +1935,15 @@ 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::
+ 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
+
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
--
gitgitgadget
^ permalink raw reply related [flat|nested] 33+ messages in thread
* Re: [PATCH v7 1/1] http: add support selecting http version
2018-11-08 23:15 ` [PATCH v7 1/1] " Force Charlie via GitGitGadget
@ 2018-11-09 3:52 ` Junio C Hamano
0 siblings, 0 replies; 33+ messages in thread
From: Junio C Hamano @ 2018-11-09 3:52 UTC (permalink / raw)
To: Force Charlie via GitGitGadget; +Cc: git, Force Charlie
"Force Charlie via GitGitGadget" <gitgitgadget@gmail.com> writes:
> +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.
> 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
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v8 0/1] http: add support selecting http version
2018-11-08 23:15 ` [PATCH v7 0/1] " Force.Charlie-I via GitGitGadget
2018-11-08 23:15 ` [PATCH v7 1/1] " Force Charlie via GitGitGadget
@ 2018-11-09 3:44 ` Force.Charlie-I via GitGitGadget
2018-11-09 3:44 ` [PATCH v8 1/1] " Force Charlie via GitGitGadget
1 sibling, 1 reply; 33+ messages in thread
From: Force.Charlie-I via GitGitGadget @ 2018-11-09 3:44 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano
Usually we don't need to set libcurl to choose which version of the HTTP
protocol to use to communicate with a server. But different versions of
libcurl, the default value is not the same.
CURL >= 7.62.0: CURL_HTTP_VERSION_2TLS CURL < 7.62: CURL_HTTP_VERSION_1_1
In order to give users the freedom to control the HTTP version, we need to
add a setting to choose which HTTP version to use.
This patch support force enable HTTP/2 or HTTP/1.1.
example:
GIT_CURL_VERBOSE=1 git2 -c http.version=HTTP/2 ls-remote https://bitbucket.org/aquariusjay/deeplab-public-ver2.git
Force Charlie (1):
http: add support selecting http version
Documentation/config.txt | 9 +++++++++
http.c | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+)
base-commit: 8858448bb49332d353febc078ce4a3abcc962efe
Published-As: https://github.com/gitgitgadget/git/releases/tags/pr-69%2Ffcharlie%2Fmaster-v8
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-69/fcharlie/master-v8
Pull-Request: https://github.com/gitgitgadget/git/pull/69
Range-diff vs v7:
1: e26fc0d8c7 ! 1: 71f8b71b34 http: add support selecting http version
@@ -78,6 +78,7 @@
+ }
+ }
+
++ warning("unknown value given to http.version: '%s'", version_string);
+ return -1; /* not found */
+}
+
--
gitgitgadget
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH v8 1/1] http: add support selecting http version
2018-11-09 3:44 ` [PATCH v8 0/1] " Force.Charlie-I via GitGitGadget
@ 2018-11-09 3:44 ` Force Charlie via GitGitGadget
0 siblings, 0 replies; 33+ messages in thread
From: Force Charlie via GitGitGadget @ 2018-11-09 3:44 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Force Charlie
From: Force Charlie <charlieio@outlook.com>
Usually we don't need to set libcurl to choose which version of the
HTTP protocol to use to communicate with a server.
But different versions of libcurl, the default value is not the same.
CURL >= 7.62.0: CURL_HTTP_VERSION_2TLS
CURL < 7.62: CURL_HTTP_VERSION_1_1
In order to give users the freedom to control the HTTP version,
we need to add a setting to choose which HTTP version to use.
Signed-off-by: Force Charlie <charlieio@outlook.com>
---
Documentation/config.txt | 9 +++++++++
http.c | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 48 insertions(+)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 41a9ff2b6a..f397942128 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -1935,6 +1935,15 @@ 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::
+ 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
+
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..bc3274804e 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,31 @@ 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;
+ }
+ }
+
+ warning("unknown value given to http.version: '%s'", version_string);
+ return -1; /* not found */
+}
+
+#endif
+
static CURL *get_curl_handle(void)
{
CURL *result = curl_easy_init();
@@ -806,6 +835,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
--
gitgitgadget
^ permalink raw reply related [flat|nested] 33+ messages in thread