Subject: Re: [PATCH v2 8/9] http: tell server that the client understands v1

From: Brandon Williams <[email-masked]>
Date: Wed, 27 Sep 2017 14:36:16 -0700

On 09/27, Junio C Hamano wrote:
> Brandon Williams <[email-masked]> writes:
> 
> > @@ -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 ;-)

Having limited experience working with HTTP, it took me a bit to
figure out how to get the server configuration right, but once I got it
working it seemed to work pretty seamlessly :)

-- 
Brandon Williams