# [PATCH] protocol-v2 doc: put HTTP headers after request

3 messages from 2018-06-22 to 2018-06-22. Participants: Josh Steadmon, Jonathan Nieder.
Thread: https://gitlist.dev/t/48765

## Josh Steadmon, 2018-06-22 19:01

Subject: [PATCH] protocol-v2 doc: put HTTP headers after request
Message-ID: <20180622190112.7559-1-steadmon@google.com>
URL: https://gitlist.dev/e/20180622190112.7559-1-steadmon%40google.com

```
HTTP servers return 400 if you send headers before the GET request.

Signed-off-by: Josh Steadmon <steadmon@google.com>
---
 Documentation/technical/protocol-v2.txt | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/Documentation/technical/protocol-v2.txt b/Documentation/technical/protocol-v2.txt
index 49bda76d2..f58f24b1e 100644
--- a/Documentation/technical/protocol-v2.txt
+++ b/Documentation/technical/protocol-v2.txt
@@ -64,9 +64,8 @@ When using the http:// or https:// transport a client makes a "smart"
 info/refs request as described in `http-protocol.txt` and requests that
 v2 be used by supplying "version=2" in the `Git-Protocol` header.
 
-   C: Git-Protocol: version=2
-   C:
    C: GET $GIT_URL/info/refs?service=git-upload-pack HTTP/1.0
+   C: Git-Protocol: version=2
 
 A v2 server would reply:
 
-- 
2.18.0.rc2.346.g013aa6912e-goog


```

## Jonathan Nieder, 2018-06-22 19:37

Subject: Re: [PATCH] protocol-v2 doc: put HTTP headers after request
Message-ID: <20180622193757.GF12013@aiede.svl.corp.google.com>
URL: https://gitlist.dev/e/20180622193757.GF12013%40aiede.svl.corp.google.com
In-Reply-To: <20180622190112.7559-1-steadmon@google.com>

```
Josh Steadmon wrote:

> HTTP servers return 400 if you send headers before the GET request.
>
> Signed-off-by: Josh Steadmon <steadmon@google.com>
> ---
>  Documentation/technical/protocol-v2.txt | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Thanks.  Congrats on your first patch! ;-)

Tested using

  openssl s_client -connect github.com:443

with input

  GET /git/git/info/refs?service=git-upload-pack HTTP/1.0
  Host: github.com
  Git-Protocol: version=2

which produces a 404 instead of the 400 that putting Git-Protocol
in front would produce.

Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>

```

## Jonathan Nieder, 2018-06-22 20:47

Subject: Re: [PATCH] protocol-v2 doc: put HTTP headers after request
Message-ID: <20180622204722.GG12013@aiede.svl.corp.google.com>
URL: https://gitlist.dev/e/20180622204722.GG12013%40aiede.svl.corp.google.com
In-Reply-To: <20180622193757.GF12013@aiede.svl.corp.google.com>

```
Jonathan Nieder wrote:
> Josh Steadmon wrote:

>> HTTP servers return 400 if you send headers before the GET request.
[...]
> Tested using
>
>   openssl s_client -connect github.com:443
>
> with input
>
>   GET /git/git/info/refs?service=git-upload-pack HTTP/1.0
>   Host: github.com
>   Git-Protocol: version=2
>
> which produces a 404 instead of the 400 that putting Git-Protocol
> in front would produce.

I figured out how to produce a 200:

	printf '%s\r\n' \
		'GET /git/git/info/refs?service=git-upload-pack HTTP/1.0' \
		'Host: github.com' \
		'User-Agent: git/jrn-at-keyboard' \
		'Git-Protocol: version=2' '' |
	openssl s_client -connect github.com:443 -quiet

The critical part is the User-Agent starting with git/.

So we should probably update Documentation/technical/http-protocol.txt
to indicate that clients MUST have a user-agent string starting with
Git/ to allow the kind of request routing that github does.

That's all orthogonal to this patch.  The patch still looks good to me.

Sincerely,
Jonathan

```
