]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
REGTESTS: cache: Add test on 'vary' other than accept-encoding
authorRemi Tricot-Le Breton <rlebreton@haproxy.com>
Wed, 24 Apr 2024 13:22:50 +0000 (15:22 +0200)
committerWilliam Lallemand <wlallemand@haproxy.com>
Mon, 29 Apr 2024 08:41:48 +0000 (10:41 +0200)
A bug related to vary and the 'accept-encoding' header was fixed in
"BUG/MEDIUM: cache: Vary not working properly on anything other than
accept-encoding". This patch adds tests specific to this bug.

reg-tests/cache/vary.vtc

index 6c8cedf337aa21827d72fcd630a10828e8dccd29..782a76ca76e8e507654a726eb919d1a303618489 100644 (file)
@@ -91,6 +91,20 @@ server s1 {
               -hdr "Content-Encoding: gzip" \
               -bodylen 59
 
+       rxreq
+       expect req.url == "/origin-referer"
+       txresp -hdr "Vary: origin,referer" \
+              -hdr "Cache-Control: max-age=5" \
+              -hdr "Content-Encoding: gzip" \
+              -bodylen 60
+
+       rxreq
+       expect req.url == "/origin-referer"
+       txresp -hdr "Vary: origin,referer" \
+              -hdr "Cache-Control: max-age=5" \
+              -hdr "Content-Encoding: gzip" \
+              -bodylen 61
+
        # Multiple Accept-Encoding headers
        rxreq
        expect req.url == "/multiple_headers"
@@ -366,6 +380,43 @@ client c1 -connect ${h1_fe_sock} {
        expect resp.bodylen == 59
        expect resp.http.X-Cache-Hit == 1
 
+       # Mixed Vary (origin + Referer)
+       txreq -url "/origin-referer" \
+               -hdr "Accept-Encoding: br, gzip" \
+               -hdr "Referer: referer" \
+               -hdr "Origin: origin"
+       rxresp
+       expect resp.status == 200
+       expect resp.bodylen == 60
+       expect resp.http.X-Cache-Hit == 0
+
+       txreq -url "/origin-referer" \
+               -hdr "Accept-Encoding: br, gzip" \
+               -hdr "Referer: referer" \
+               -hdr "Origin: origin"
+       rxresp
+       expect resp.status == 200
+       expect resp.bodylen == 60
+       expect resp.http.X-Cache-Hit == 1
+
+       txreq -url "/origin-referer" \
+               -hdr "Accept-Encoding: br, gzip" \
+               -hdr "Referer: other-referer" \
+               -hdr "Origin: other-origin"
+       rxresp
+       expect resp.status == 200
+       expect resp.bodylen == 61
+       expect resp.http.X-Cache-Hit == 0
+
+       txreq -url "/origin-referer" \
+               -hdr "Accept-Encoding: br, gzip" \
+               -hdr "Referer: other-referer" \
+               -hdr "Origin: other-origin"
+       rxresp
+       expect resp.status == 200
+       expect resp.bodylen == 61
+       expect resp.http.X-Cache-Hit == 1
+
        # Multiple Accept-encoding headers
        txreq -url "/multiple_headers" \
                -hdr "Accept-Encoding: gzip" \