1varnishtest "Test Vary with ESI and gzip/gunzip" 2 3server s1 { 4 rxreq 5 expect req.url == "/foo" 6 txresp -body "foo" 7 8 rxreq 9 expect req.url == "/bar" 10 txresp -gzipbody "bar" 11 12 rxreq 13 expect req.url == "/baz" 14 txresp -body "baz" 15 16 rxreq 17 expect req.url == "/qux" 18 txresp -hdr "Vary: qux" -gzipbody "qux" 19 20 rxreq 21 expect req.url == "/fubar" 22 txresp -hdr "Vary: fubar, Accept-Encoding" -gzipbody "fubar" 23 24 rxreq 25 expect req.url == "/foobar" 26 txresp -gzipbody "foobar" 27 28 rxreq 29 expect req.url == "/foobaz" 30 txresp -hdr "Vary: foobaz" -gzipbody "foobaz" 31 32 rxreq 33 expect req.url == "/fooqux" 34 txresp -hdr "Vary: fooqux, Accept-Encoding" -gzipbody "fooqux" 35} -start 36 37varnish v1 -arg "-p feature=+esi_disable_xml_check" -vcl+backend { 38 sub vcl_backend_response { 39 set beresp.http.filters1 = beresp.filters; 40 set beresp.do_esi = true; 41 if (bereq.url ~ "/baz") { 42 set beresp.do_gzip = true; 43 } elif (bereq.url ~ "/foo(bar|baz|qux)") { 44 set beresp.do_gunzip = true; 45 } 46 set beresp.http.filters2 = beresp.filters; 47 } 48} -start 49 50client c1 { 51 # /foo 52 txreq -url /foo 53 rxresp 54 expect resp.body == "foo" 55 expect resp.http.Vary == <undef> 56 57 txreq -url /foo -hdr "Accept-Encoding: gzip" 58 rxresp 59 expect resp.body == "foo" 60 expect resp.http.Vary == <undef> 61 62 # /bar 63 txreq -url /bar 64 rxresp 65 expect resp.body == "bar" 66 expect resp.http.Vary == "Accept-Encoding" 67 68 txreq -url /bar -hdr "Accept-Encoding: gzip" 69 rxresp 70 expect resp.bodylen == 34 71 expect resp.http.Vary == "Accept-Encoding" 72 73 # /baz 74 txreq -url /baz 75 rxresp 76 expect resp.body == "baz" 77 expect resp.http.Vary == "Accept-Encoding" 78 79 txreq -url /baz -hdr "Accept-Encoding: gzip" 80 rxresp 81 expect resp.bodylen == 34 82 expect resp.http.Vary == "Accept-Encoding" 83 84 # /qux 85 txreq -url /qux 86 rxresp 87 expect resp.body == "qux" 88 expect resp.http.Vary == "qux, Accept-Encoding" 89 90 txreq -url /qux -hdr "Accept-Encoding: gzip" 91 rxresp 92 expect resp.bodylen == 34 93 expect resp.http.Vary == "qux, Accept-Encoding" 94 95 # /fubar 96 txreq -url /fubar 97 rxresp 98 expect resp.body == "fubar" 99 expect resp.http.Vary == "fubar, Accept-Encoding" 100 101 txreq -url /fubar -hdr "Accept-Encoding: gzip" 102 rxresp 103 expect resp.bodylen == 36 104 expect resp.http.Vary == "fubar, Accept-Encoding" 105 106 # /foobar 107 txreq -url /foobar 108 rxresp 109 expect resp.body == "foobar" 110 expect resp.http.Vary == <undef> 111 112 txreq -url /foobar -hdr "Accept-Encoding: gzip" 113 rxresp 114 expect resp.body == "foobar" 115 expect resp.http.Vary == <undef> 116 117 # /foobaz 118 txreq -url /foobaz 119 rxresp 120 expect resp.body == "foobaz" 121 expect resp.http.Vary == "foobaz" 122 123 txreq -url /foobaz -hdr "Accept-Encoding: gzip" 124 rxresp 125 expect resp.body == "foobaz" 126 expect resp.http.Vary == "foobaz" 127 128 # /fooqux 129 txreq -url /fooqux 130 rxresp 131 expect resp.body == "fooqux" 132 expect resp.http.Vary == "fooqux, Accept-Encoding" 133 134 txreq -url /fooqux -hdr "Accept-Encoding: gzip" 135 rxresp 136 expect resp.body == "fooqux" 137 expect resp.http.Vary == "fooqux, Accept-Encoding" 138} -run 139