t5559: fix test failures with LIB_HTTPD_SSL
One test needs to be tweaked in order for t5559 to pass with SSL/TLS set up. When we make our initial clone, we check that the curl trace of requests is what we expected. But we need to fix two things: - along with ignoring "data" lines from the trace, we need to ignore "SSL data" lines - when TLS is used, the server is able to tell the client (via ALPN) that it supports HTTP/2 before the first HTTP request is made. So rather than request an upgrade using an HTTP header, it can just speak HTTP/2 immediately With this patch, running: LIB_HTTPD_SSL=1 ./t5559-http-fetch-smart-http2.sh works, whereas it did not before. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Feb 23, 2023 at 06:07 UTC
86190028a813786bb8f92a93ab07b44ac5f005a1
1 file changed
+18
-5
t/t5551-http-fetch-smart.sh
+18
-5
@@ -33,8 +33,19 @@ test_expect_success 'create http-accessible bare repository' '
33
setup_askpass_helper
34
35
test_expect_success 'clone http repository' '
36
+ if test_have_prereq HTTP2 && test "$HTTPD_PROTO" = "https"
37
+ then
38
+ # ALPN lets us immediately use HTTP/2; likewise, POSTs with
39
+ # bodies can use it because they do not need to upgrade
40
+ INITIAL_PROTO=HTTP/2
41
+ else
42
+ # either we are not using HTTP/2, or the initial
43
+ # request is sent via HTTP/1.1 and asks for upgrade
44
+ INITIAL_PROTO=HTTP/1.1
45
+ fi &&
46
+
47
cat >exp.raw <<-EOF &&
37
- > GET /smart/repo.git/info/refs?service=git-upload-pack HTTP/1.1
48
+ > GET /smart/repo.git/info/refs?service=git-upload-pack $INITIAL_PROTO
49
> accept: */*
50
> accept-encoding: ENCODINGS
51
> accept-language: ko-KR, *;q=0.9
@@ -44,25 +55,25 @@ test_expect_success 'clone http repository' '
55
< pragma: no-cache
56
< cache-control: no-cache, max-age=0, must-revalidate
57
< content-type: application/x-git-upload-pack-advertisement
47
- > POST /smart/repo.git/git-upload-pack HTTP/1.1
58
+ > POST /smart/repo.git/git-upload-pack $INITIAL_PROTO
59
> accept-encoding: ENCODINGS
60
> content-type: application/x-git-upload-pack-request
61
> accept: application/x-git-upload-pack-result
62
> accept-language: ko-KR, *;q=0.9
63
{V2} > git-protocol: version=2
64
> content-length: xxx
54
- < HTTP/1.1 200 OK
65
+ < $INITIAL_PROTO 200 OK
66
< pragma: no-cache
67
< cache-control: no-cache, max-age=0, must-revalidate
68
< content-type: application/x-git-upload-pack-result
58
- {V2} > POST /smart/repo.git/git-upload-pack HTTP/1.1
69
+ {V2} > POST /smart/repo.git/git-upload-pack $INITIAL_PROTO
70
{V2} > accept-encoding: ENCODINGS
71
{V2} > content-type: application/x-git-upload-pack-request
72
{V2} > accept: application/x-git-upload-pack-result
73
{V2} > accept-language: ko-KR, *;q=0.9
74
{V2} > git-protocol: version=2
75
{V2} > content-length: xxx
65
- {V2} < HTTP/1.1 200 OK
76
+ {V2} < $INITIAL_PROTO 200 OK
77
{V2} < pragma: no-cache
78
{V2} < cache-control: no-cache, max-age=0, must-revalidate
79
{V2} < content-type: application/x-git-upload-pack-result
@@ -96,6 +107,8 @@ test_expect_success 'clone http repository' '
107
s/= Recv header://
108
/^<= Recv data/d
109
/^=> Send data/d
110
+ /^<= Recv SSL data/d
111
+ /^=> Send SSL data/d
112
/^$/d
113
/^< $/d
114