Skip to content

Commit 8dfe36b

Browse files
peffgitster
authored andcommitted
t5551: handle HTTP/2 when checking curl trace
We check that the curl trace of a clone has the lines we expect, but this won't work when we run the test under t5559, because a few details are different under HTTP/2 (but nobody noticed because it only happens when you manually set GIT_TEST_PROTOCOL_VERSION to "0"). We can handle both HTTP protocols with a few tweaks: - we'll drop the HTTP "101 Switching Protocols" response, as well as various protocol upgrade headers. These details aren't interesting to us. We just want to make sure the correct protocol was used (and we do in the main request/response lines). - successful HTTP/2 responses just say "200" and not "200 OK"; we can normalize these - replace HTTP/1.1 with a variable in the request/response lines. We can use the existing $HTTP_PROTO for this, as it's already set to "HTTP/2" when appropriate. We do need to tweak the fallback value to "HTTP/1.1" to match what curl will write (prior to this patch, the fallback value didn't matter at all; we only checked if it was the literal string "HTTP/2"). Note that several lines still expect HTTP/1.1 unconditionally. The first request does so because the client requests an upgrade during the request. The POST request and response do so because you can't do an upgrade if there is a request body. (This will all be different if we trigger HTTP/2 via ALPN, but the tests aren't yet capable of that). This is enough to let: GIT_TEST_PROTOCOL_VERSION=0 ./t5559-http-fetch-smart-http2.sh pass the "clone http repository" test (but there are some other failures later on). Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4a21230 commit 8dfe36b

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

t/t5551-http-fetch-smart.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22

3-
: ${HTTP_PROTO:=HTTP}
3+
: ${HTTP_PROTO:=HTTP/1.1}
44
test_description="test smart fetching over http via http-backend ($HTTP_PROTO)"
55
GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
66
export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
@@ -33,13 +33,13 @@ test_expect_success 'create http-accessible bare repository' '
3333
setup_askpass_helper
3434

3535
test_expect_success 'clone http repository' '
36-
cat >exp <<-\EOF &&
36+
cat >exp <<-EOF &&
3737
> GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1
3838
> accept: */*
3939
> accept-encoding: ENCODINGS
4040
> accept-language: ko-KR, *;q=0.9
4141
> pragma: no-cache
42-
< HTTP/1.1 200 OK
42+
< $HTTP_PROTO 200 OK
4343
< pragma: no-cache
4444
< cache-control: no-cache, max-age=0, must-revalidate
4545
< content-type: application/x-git-upload-pack-advertisement
@@ -83,6 +83,14 @@ test_expect_success 'clone http repository' '
8383
s/^/> /
8484
}
8585
86+
/^< HTTP/ {
87+
s/200$/200 OK/
88+
}
89+
/^< HTTP\\/1.1 101/d
90+
/^[><] connection: /d
91+
/^[><] upgrade: /d
92+
/^> http2-settings: /d
93+
8694
/^> user-agent: /d
8795
/^> host: /d
8896
/^> POST /,$ {

0 commit comments

Comments
 (0)