http: add support selecting http version
cover http: add support selecting http version
Normally, git doesn't need to set curl to select the HTTP version, it works fine without HTTP2. Adding HTTP2 support is a icing on the cake.
When http.version=20 is set, git will attempt to request the server using HTTP2. If the remote server does not support HTTP2, it is no different. Currently bitbucket supports HTTP2 and is available for testing.
example:
GIT_CURL_VERBOSE=1 git2 -c http.version=20 ls-remote https://bitbucket.org/aquariusjay/deeplab-public-ver2.git
Force Charlie (1):
http: add support selecting http version
http.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
base-commit: 8858448bb49332d353febc078ce4a3abcc962efe
Published-As: https://github.com/gitgitgadget/git/releases/tags/pr-69%2Ffcharlie%2Fmaster-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-69/fcharlie/master-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/69
Signature · 1 line
gitgitgadget
PATCH 1/1 http: add support selecting http version
From: Force Charlie <[email protected]>
--- http.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
http.c +12 -0
@@ -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
Signature · 1 line
gitgitgadget
Quoted 1 line · Force.Charlie-I via GitGitGadget
Normally, git doesn't need to set curl to select the HTTP version, it works fine without HTTP2. Adding HTTP2 support is a icing on the cake.
Just a FYI:
Starting with libcurl 7.62.0 (released a week ago), it now defaults to the "2TLS" setting unless you tell it otherwise. With 2TLS, libcurl will attempt to use HTTP/2 for HTTPS URLs.
Signature · 1 line
/ daniel.haxx.se
Quoted 10 lines · Daniel Stenberg
Quoted 2 lines · Force.Charlie-I via GitGitGadget
Normally, git doesn't need to set curl to select the HTTP version, it works fine without HTTP2. Adding HTTP2 support is a icing on the cake.
Just a FYI:
Starting with libcurl 7.62.0 (released a week ago), it now defaults to the "2TLS" setting unless you tell it otherwise. With 2TLS, libcurl will attempt to use HTTP/2 for HTTPS URLs.
With this information, I think I would rather we rely on libcurl to do this rather than putting it in Git. Users will automatically get the best supported protocol instead of having to configure it manually.
Signature · 2 lines
brian m. carlson: Houston, Texas, US OpenPGP: https://keybase.io/bk2204
v2 cover http: add support selecting http version
In reply to Force.Charlie-I via GitGitGadgetNormally, git doesn't need to set curl to select the HTTP version, it works fine without HTTP2. Adding HTTP2 support is a icing on the cake.
When http.version=20 is set, git will attempt to request the server using HTTP2. If the remote server does not support HTTP2, it is no different. Currently bitbucket supports HTTP2 and is available for testing.
example:
GIT_CURL_VERBOSE=1 git2 -c http.version=20 ls-remote https://bitbucket.org/aquariusjay/deeplab-public-ver2.git
Force Charlie (3):
http: add support selecting http version support force use http 1.1
fix curl version to support CURL_HTTP_VERSION_2TLS
http.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
base-commit: 8858448bb49332d353febc078ce4a3abcc962efe
Published-As: https://github.com/gitgitgadget/git/releases/tags/pr-69%2Ffcharlie%2Fmaster-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-69/fcharlie/master-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/69
Range-diff vs v1:
1: 4f5a935c43 = 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
Signature · 1 line
gitgitgadget
PATCH v2 1/3 http: add support selecting http version
From: Force Charlie <[email protected]>
--- http.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
http.c +12 -0
@@ -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
Signature · 1 line
gitgitgadget
PATCH v2 2/3 support force use http 1.1
In reply to Force.Charlie-I via GitGitGadgetFrom: Force Charlie <[email protected]>
--- http.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
http.c +9 -6
@@ -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
Signature · 1 line
gitgitgadget
PATCH v2 3/3 fix curl version to support CURL_HTTP_VERSION_2TLS
In reply to Force.Charlie-I via GitGitGadgetFrom: Force Charlie <[email protected]>
--- http.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
http.c +2 -2
@@ -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 );
Signature · 1 line
gitgitgadget
Quoted 12 lines · Force Charlie via GitGitGadget
From: Force Charlie <[email protected]>
Signed-off-by Force Charlie <[email protected]>--- http.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)http.c +0
-0
http.c char curl_errorstr[CURL_ERROR_SIZE]; · line 51
Quoted 4 lines
http.c +1
-0@@ -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 ;
Is there any reason that we need to have this variable's value to be "int"? I _think_ in this patch, the variable is used to choose between the default and "HTTP/2", and I do not think the updated code can choose any other new value that may be supported by an even newer cURL library without further update, i.e. we'd need a variant of "if the configuration asks HTTP/2 then use CURLOPT_HTTP_VERSION with CURL_HTTP_VERSION_2" for the new choice.
So I'd think it would not add much value to force end users use a rather cryptic "20" (vs "11") to choose between "2" and "1.1". Why not use spell it out, e.g. using the official name of the protocol "HTTP/2" (vs "HTTP/1.1"), with a "const char *" instead?
The new configuration variable and the possible values it can take must be documented, of course. I think it would make the description far less embarrassing if we say "HTTP/2" etc. rather than "20", "11", etc.
http.c static void process_curl_messages(void) · line 289
Quoted 6 lines
http.c +2
-0@@ -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);
STYLE. Missing SP after comma, and around assignment.
http.c static CURL *get_curl_handle(void) · line 815
Quoted 11 lines
http.c +4
-0+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 ){
STYLE. Missing SP before opening paren and after closing paren.
http.c static CURL *get_curl_handle(void) · line 816
Quoted 1 line
http.c +1
-0+/* CURL Enable HTTP2*/
STYLE. Missing SP before closing asterisk-slash.
http.c static CURL *get_curl_handle(void) · line 819
Quoted 3 lines
http.c +3
-0+ curl_easy_setopt(result, CURLOPT_HTTP_VERSION,CURL_HTTP_VERSION_2); + } +#endif
Shouldn't this block also handle the other values, e.g. "11"?
I _think_ the curl_http_version variable (be it an deci-int, or a const char *) should be initialized to a value that you can use to notice that the configuration did not specify any, and then this part should become more like
if (curl_http_version && !get_curl_http_version_opt(curl_http_version, &opt)) curl_easy_setopt(result, CURL_HTTP_VERSION, opt);
with a helper function like this:
static int get_curl_http_version_opt(const char *version_string, long *opt)
{
int i;
static struct {
const char *name;
lnog 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 */
}which would make it trivial to support new values later.
Quoted 3 lines
http.c +0
-0#if LIBCURL_VERSION_NUM >=0x070907 curl_easy_setopt (result,CURLOPT_NETRC ,CURL_NETRC_OPTIONAL );#endif
Quoted 8 lines · brian m. carlson
Quoted 7 lines · Daniel Stenberg
Quoted 2 lines · Force.Charlie-I via GitGitGadget
Normally, git doesn't need to set curl to select the HTTP version, it works fine without HTTP2. Adding HTTP2 support is a icing on the cake.
Just a FYI:
Quoted 7 lines
Quoted 3 lines
Starting with libcurl 7.62.0 (released a week ago), it now defaults to the "2TLS" setting unless you tell it otherwise. With 2TLS, libcurl will attempt to use HTTP/2 for HTTPS URLs.
With this information, I think I would rather we rely on libcurl to do this rather than putting it in Git. Users will automatically get the best supported protocol instead of having to configure it manually.
Yup. I suspect that the mechanism _might_ turn out to be useful to force downgrading, though.
v3 cover http: add support selecting http version
In reply to Force.Charlie-I via GitGitGadgetNormally, 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 (4):
http: add support selecting http version support force use http 1.1
fix curl version to support CURL_HTTP_VERSION_2TLS
http: change http.version value type
http.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)
base-commit: 8858448bb49332d353febc078ce4a3abcc962efe
Published-As: https://github.com/gitgitgadget/git/releases/tags/pr-69%2Ffcharlie%2Fmaster-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-69/fcharlie/master-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/69
Range-diff vs v2:
1: 4f5a935c43 = 1: 4f5a935c43 http: add support selecting http version 2: 06e9685d2b = 2: 06e9685d2b support force use http 1.1 3: eee67d8356 = 3: eee67d8356 fix curl version to support CURL_HTTP_VERSION_2TLS -: ---------- > 4: ef975b6093 http: change http.version value type
Signature · 1 line
gitgitgadget
PATCH v3 1/4 http: add support selecting http version
From: Force Charlie <[email protected]>
--- http.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
http.c +12 -0
@@ -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
Signature · 1 line
gitgitgadget
PATCH v3 2/4 support force use http 1.1
In reply to Force.Charlie-I via GitGitGadgetFrom: Force Charlie <[email protected]>
--- http.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
http.c +9 -6
@@ -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
Signature · 1 line
gitgitgadget
PATCH v3 3/4 fix curl version to support CURL_HTTP_VERSION_2TLS
In reply to Force.Charlie-I via GitGitGadgetFrom: Force Charlie <[email protected]>
--- http.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
http.c +2 -2
@@ -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 );
Signature · 1 line
gitgitgadget
PATCH v3 4/4 http: change http.version value type
In reply to Force.Charlie-I via GitGitGadgetFrom: Force Charlie <[email protected]>
--- http.c | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-)
http.c +30 -9
@@ -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,10 @@ 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 ); +long opt=-1 ; +if (curl_http_version &&!get_curl_http_version_opt (curl_http_version, &opt)) { +/* Set request use http version */ +curl_easy_setopt (result,CURLOPT_HTTP_VERSION ,opt); }#endif
Signature · 1 line
gitgitgadget
v4 cover http: add support selecting http version
In reply to Force.Charlie-I via GitGitGadgetNormally, 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 (4):
http: add support selecting http version support force use http 1.1
fix curl version to support CURL_HTTP_VERSION_2TLS
http: change http.version value type
http.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
base-commit: 8858448bb49332d353febc078ce4a3abcc962efe
Published-As: https://github.com/gitgitgadget/git/releases/tags/pr-69%2Ffcharlie%2Fmaster-v4
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-69/fcharlie/master-v4
Pull-Request: https://github.com/gitgitgadget/git/pull/69
Range-diff vs v3:
1: 4f5a935c43 = 1: 4f5a935c43 http: add support selecting http version
2: 06e9685d2b = 2: 06e9685d2b support force use http 1.1
3: eee67d8356 = 3: eee67d8356 fix curl version to support CURL_HTTP_VERSION_2TLS
4: ef975b6093 ! 4: 0a7794722b http: change http.version value type
@@ -67,10 +67,12 @@
- 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);
-+ long opt=-1;
-+ if (curl_http_version &&!get_curl_http_version_opt(curl_http_version, &opt)) {
-+ /* Set request use http version */
-+ curl_easy_setopt(result, CURLOPT_HTTP_VERSION,opt);
++ 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);
++ }
}
#endifSignature · 1 line
gitgitgadget
PATCH v4 3/4 fix curl version to support CURL_HTTP_VERSION_2TLS
From: Force Charlie <[email protected]>
--- http.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
http.c +2 -2
@@ -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 );
Signature · 1 line
gitgitgadget
PATCH v4 2/4 support force use http 1.1
In reply to Force.Charlie-I via GitGitGadgetFrom: Force Charlie <[email protected]>
--- http.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
http.c +9 -6
@@ -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
Signature · 1 line
gitgitgadget
PATCH v4 4/4 http: change http.version value type
In reply to Force.Charlie-I via GitGitGadgetFrom: Force Charlie <[email protected]>
--- http.c | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-)
http.c +32 -9
@@ -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
Signature · 1 line
gitgitgadget
PATCH v4 1/4 http: add support selecting http version
In reply to Force.Charlie-I via GitGitGadgetFrom: Force Charlie <[email protected]>
--- http.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
http.c +12 -0
@@ -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
Signature · 1 line
gitgitgadget
Quoted 7 lines · Force.Charlie-I via GitGitGadget
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:
Quoted 7 lines
GIT_CURL_VERBOSE=1 git2 -c http.version=HTTP/2 ls-remote https://bitbucket.org/aquariusjay/deeplab-public-ver2.git
Force Charlie (4):
http: add support selecting http version support force use http 1.1
fix curl version to supportCURL_HTTP_VERSION_2TLS
http: change http.version value type
When somebody reads over these four patches as a first-time reader, I think s/he notices a couple of things:
- In the proposed log messages, there is no explanation on the reason why we are doing these changes.
- Each of the steps n/4 (n > 1) looks more like "oops, it was a mistake that we did not do this in earlier patch, and here is to correct that".
- There is no test or documentation.
I suspect that a single patch that updates http.c, Documentation/ and t/ at the same time should be sufficient for a change of this size.
Thanks.
Quoted 15 lines
http.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+)base-commit:
8858448bb49332d353febc078ce4a3abcc962efe
Published-As: https://github.com/gitgitgadget/git/releases/tags/pr-69%2Ffcharlie%2Fmaster-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-69/fcharlie/master-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/69Range-diff vs v2:
1: 4f5a935c43 = 1: 4f5a935c43 http: add support selecting http version 2: 06e9685d2b = 2: 06e9685d2b support force use http 1.1 3: eee67d8356 = 3: eee67d8356 fix curl version to support CURL_HTTP_VERSION_2TLS -: ---------- > 4: ef975b6093 http: change http.version value type
v5 cover http: add support selecting http version
In reply to Force.Charlie-I via GitGitGadgetNormally, 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 <[email protected]>
- http: change http.version value type
+ http: add support selecting http version
Signed-off-by: Force Charlie <[email protected]>
@@ -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
- Signature · 1 line
gitgitgadget
PATCH v5 1/1 http: add support selecting http version
From: Force Charlie <[email protected]>
--- http.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+)
http.c +38 -0
@@ -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
Signature · 1 line
gitgitgadget
v6 cover http: add support selecting http version
In reply to Force.Charlie-I via GitGitGadgetUsually 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.
+
+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
Signature · 1 line
gitgitgadget
PATCH v6 1/1 http: add support selecting http version
From: Force Charlie <[email protected]>
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.
--- Documentation/config.txt | 9 +++++++++ http.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+)
Documentation/config.txt +9 -0
@@ -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
http.c +38 -0
@@ -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
Signature · 1 line
gitgitgadget
http.c static void process_curl_messages(void) · line 287
Quoted 10 lines · Force Charlie via GitGitGadget
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 <[email protected]>---
http.c +1
-0@@ -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
http.c static CURL *get_curl_handle(void) · line 838
Quoted 8 lines
http.c +7
-0+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
Quoted 2 lines
http.c +2
-0+ } + }
v7 cover http: add support selecting http version
In reply to Force.Charlie-I via GitGitGadgetUsually 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);
+ }
+ }
+#endifSignature · 1 line
gitgitgadget
PATCH v7 1/1 http: add support selecting http version
From: Force Charlie <[email protected]>
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.
--- Documentation/config.txt | 9 +++++++++ http.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+)
Documentation/config.txt +9 -0
@@ -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
http.c +38 -0
@@ -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
Signature · 1 line
gitgitgadget
Quoted 9 lines · Force Charlie via GitGitGadget
http.c +9
-0+#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.c static long get_curl_allowed_protocols(int from_user) · line 814
Quoted 10 lines
http.c +10
-0+ { "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?
Quoted 7 lines · Eric Sunshine
http.c static void process_curl_messages(void) · line 287
Quoted 4 lines
http.c +1
-0@@ -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
Quoted 13 lines
http.c static CURL *get_curl_handle(void) · line 838
Quoted 8 lines
http.c +7
-0+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
Quoted 2 lines
(quoted diff) +2
-0+ } + }
Thanks, both. This is almost done, I think.
v8 cover http: add support selecting http version
In reply to Force.Charlie-I via GitGitGadgetUsually 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 */
+}
+Signature · 1 line
gitgitgadget
PATCH v8 1/1 http: add support selecting http version
From: Force Charlie <[email protected]>
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.
--- Documentation/config.txt | 9 +++++++++ http.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+)
Documentation/config.txt +9 -0
@@ -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
http.c +39 -0
@@ -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
Signature · 1 line
gitgitgadget
Documentation/config.txt http.saveCookies:: · line 1946
Quoted 9 lines · Force Charlie via GitGitGadget
Documentation/config.txt +9
-0+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.
Quoted 73 lines
http.sslVersion::
Documentation/config.txt +0
-0The SSL version to use when negotiating an SSL connection, if you want to force the default. The available and default versionhttp.c +38
-0@@ -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