blob: 0a060e4bcc91f29bc2affcb161dd346a2d56cd33 [file] [log] [blame]
Tim Duesterhus721d6862019-06-17 16:10:07 +02001varnishtest "Compression sets Vary header"
2
3#REQUIRE_VERSION=1.9
4#REQUIRE_OPTION=ZLIB|SLZ
5
6feature ignore_unknown_macro
7
8server s1 {
9 rxreq
10 expect req.url == "/plain/accept-encoding-gzip"
11 expect req.http.accept-encoding == "gzip"
12 txresp \
13 -hdr "Content-Type: text/plain" \
14 -bodylen 100
15
16 rxreq
17 expect req.url == "/plain/accept-encoding-invalid"
18 expect req.http.accept-encoding == "invalid"
19 txresp \
20 -hdr "Content-Type: text/plain" \
21 -bodylen 100
22
23 rxreq
24 expect req.url == "/plain/accept-encoding-null"
25 expect req.http.accept-encoding == "<undef>"
26 txresp \
27 -hdr "Content-Type: text/plain" \
28 -bodylen 100
29
30 rxreq
31 expect req.url == "/html/accept-encoding-gzip"
32 expect req.http.accept-encoding == "gzip"
33 txresp \
34 -hdr "Content-Type: text/html" \
35 -bodylen 100
36
37 rxreq
38 expect req.url == "/html/accept-encoding-invalid"
39 expect req.http.accept-encoding == "invalid"
40 txresp \
41 -hdr "Content-Type: text/html" \
42 -bodylen 100
43
44
45 rxreq
46 expect req.url == "/html/accept-encoding-null"
47 expect req.http.accept-encoding == "<undef>"
48 txresp \
49 -hdr "Content-Type: text/html" \
50 -bodylen 100
51
52 rxreq
53 expect req.url == "/dup-etag/accept-encoding-gzip"
54 expect req.http.accept-encoding == "gzip"
55 txresp \
56 -hdr "Content-Type: text/plain" \
57 -hdr "ETag: \"123\"" \
58 -hdr "ETag: \"123\"" \
59 -bodylen 100
60} -repeat 2 -start
61
62
63haproxy h1 -conf {
64 defaults
65 mode http
66 ${no-htx} option http-use-htx
67 timeout connect 1s
68 timeout client 1s
69 timeout server 1s
70
71 frontend fe-gzip
72 bind "fd@${fe_gzip}"
73 default_backend be-gzip
74
75 backend be-gzip
76 compression algo gzip
77 compression type text/plain
78 server www ${s1_addr}:${s1_port}
79
80 frontend fe-nothing
81 bind "fd@${fe_nothing}"
82 default_backend be-nothing
83
84 backend be-nothing
85 server www ${s1_addr}:${s1_port}
86} -start
87
88client c1 -connect ${h1_fe_gzip_sock} {
89 txreq -url "/plain/accept-encoding-gzip" \
90 -hdr "Accept-Encoding: gzip"
91 rxresp
92 expect resp.status == 200
93 expect resp.http.content-encoding == "gzip"
94 expect resp.http.vary == "Accept-Encoding"
95 gunzip
96 expect resp.bodylen == 100
97
98 txreq -url "/plain/accept-encoding-invalid" \
99 -hdr "Accept-Encoding: invalid"
100 rxresp
101 expect resp.status == 200
102 expect resp.http.vary == "<undef>"
103 expect resp.bodylen == 100
104
105 txreq -url "/plain/accept-encoding-null"
106 rxresp
107 expect resp.status == 200
108 expect resp.http.vary == "<undef>"
109 expect resp.bodylen == 100
110
111 txreq -url "/html/accept-encoding-gzip" \
112 -hdr "Accept-Encoding: gzip"
113 rxresp
114 expect resp.status == 200
115 expect resp.http.vary == "<undef>"
116 expect resp.bodylen == 100
117
118 txreq -url "/html/accept-encoding-invalid" \
119 -hdr "Accept-Encoding: invalid"
120 rxresp
121 expect resp.status == 200
122 expect resp.http.vary == "<undef>"
123 expect resp.bodylen == 100
124
125 txreq -url "/html/accept-encoding-null"
126 rxresp
127 expect resp.status == 200
128 expect resp.http.vary == "<undef>"
129 expect resp.bodylen == 100
130
131 txreq -url "/dup-etag/accept-encoding-gzip" \
132 -hdr "Accept-Encoding: gzip"
133 rxresp
134 expect resp.status == 200
135 expect resp.http.vary == "<undef>"
136 expect resp.bodylen == 100
137} -run
138
139# This Client duplicates c1, against the "nothing" frontend, ensuring no Vary header is ever set.
140client c2 -connect ${h1_fe_nothing_sock} {
141 txreq -url "/plain/accept-encoding-gzip" \
142 -hdr "Accept-Encoding: gzip"
143 rxresp
144 expect resp.status == 200
145 expect resp.http.vary == "<undef>"
146 expect resp.bodylen == 100
147
148 txreq -url "/plain/accept-encoding-invalid" \
149 -hdr "Accept-Encoding: invalid"
150 rxresp
151 expect resp.status == 200
152 expect resp.http.vary == "<undef>"
153 expect resp.bodylen == 100
154
155 txreq -url "/plain/accept-encoding-null"
156 rxresp
157 expect resp.status == 200
158 expect resp.http.vary == "<undef>"
159 expect resp.bodylen == 100
160
161 txreq -url "/html/accept-encoding-gzip" \
162 -hdr "Accept-Encoding: gzip"
163 rxresp
164 expect resp.status == 200
165 expect resp.http.vary == "<undef>"
166 expect resp.bodylen == 100
167
168 txreq -url "/html/accept-encoding-invalid" \
169 -hdr "Accept-Encoding: invalid"
170 rxresp
171 expect resp.status == 200
172 expect resp.http.vary == "<undef>"
173 expect resp.bodylen == 100
174
175 txreq -url "/html/accept-encoding-null"
176 rxresp
177 expect resp.status == 200
178 expect resp.http.vary == "<undef>"
179 expect resp.bodylen == 100
180
181 txreq -url "/dup-etag/accept-encoding-gzip" \
182 -hdr "Accept-Encoding: gzip"
183 rxresp
184 expect resp.status == 200
185 expect resp.http.vary == "<undef>"
186 expect resp.bodylen == 100
187} -run