Re: [PATCH v2 8/9] http: tell server that the client understands v1
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 27, 2017, 06:24 UTC
- Message-ID
- <xmqqfub864m8.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <20170926235627.79606-9-bmwill@google.com>
Brandon Williams <bmwill@google.com> writes:
Show 53 quoted lines
> @@ -897,6 +898,21 @@ static void set_from_env(const char **var, const char *envname)
> *var = val;
> }
>
> +static void protocol_http_header(void)
> +{
> + if (get_protocol_version_config() > 0) {
> + struct strbuf protocol_header = STRBUF_INIT;
> +
> + strbuf_addf(&protocol_header, GIT_PROTOCOL_HEADER ": version=%d",
> + get_protocol_version_config());
> +
> +
> + extra_http_headers = curl_slist_append(extra_http_headers,
> + protocol_header.buf);
> + strbuf_release(&protocol_header);
> + }
> +}
> +
> void http_init(struct remote *remote, const char *url, int proactive_auth)
> {
> char *low_speed_limit;
> @@ -927,6 +943,8 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
> if (remote)
> var_override(&http_proxy_authmethod, remote->http_proxy_authmethod);
>
> + protocol_http_header();
> +
> pragma_header = curl_slist_append(http_copy_default_headers(),
> "Pragma: no-cache");
> no_pragma_header = curl_slist_append(http_copy_default_headers(),
> diff --git a/t/lib-httpd/apache.conf b/t/lib-httpd/apache.conf
> index 0642ae7e6..df1943631 100644
> --- a/t/lib-httpd/apache.conf
> +++ b/t/lib-httpd/apache.conf
> @@ -67,6 +67,9 @@ LockFile accept.lock
> <IfModule !mod_unixd.c>
> LoadModule unixd_module modules/mod_unixd.so
> </IfModule>
> +<IfModule !mod_setenvif.c>
> + LoadModule setenvif_module modules/mod_setenvif.so
> +</IfModule>
> </IfVersion>
>
> PassEnv GIT_VALGRIND
> @@ -76,6 +79,10 @@ PassEnv ASAN_OPTIONS
> PassEnv GIT_TRACE
> PassEnv GIT_CONFIG_NOSYSTEM
>
> +<IfVersion >= 2.4>
> + SetEnvIf Git-Protocol ".*" GIT_PROTOCOL=$0
> +</IfVersion>
> +It is very nice to see that only with a single extra HTTP header and the server configuration, everybody else does not have to care how the version information is plumbed through ;-)