blob: ec6341b3f1aa233fe818b17af924dbcab007955f [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 {
Willy Tarreaue1465c12021-05-09 14:41:41 +020064 global
65 # WT: limit false-positives causing "HTTP header incomplete" due to
66 # idle server connections being randomly used and randomly expiring
67 # under us.
68 tune.idle-pool.shared off
69
Tim Duesterhus721d6862019-06-17 16:10:07 +020070 defaults
71 mode http
Tim Duesterhus721d6862019-06-17 16:10:07 +020072 timeout connect 1s
73 timeout client 1s
74 timeout server 1s
75
76 frontend fe-gzip
77 bind "fd@${fe_gzip}"
78 default_backend be-gzip
79
80 backend be-gzip
81 compression algo gzip
82 compression type text/plain
83 server www ${s1_addr}:${s1_port}
84
85 frontend fe-nothing
86 bind "fd@${fe_nothing}"
87 default_backend be-nothing
88
89 backend be-nothing
90 server www ${s1_addr}:${s1_port}
91} -start
92
93client c1 -connect ${h1_fe_gzip_sock} {
94 txreq -url "/plain/accept-encoding-gzip" \
95 -hdr "Accept-Encoding: gzip"
96 rxresp
97 expect resp.status == 200
98 expect resp.http.content-encoding == "gzip"
99 expect resp.http.vary == "Accept-Encoding"
100 gunzip
101 expect resp.bodylen == 100
102
103 txreq -url "/plain/accept-encoding-invalid" \
104 -hdr "Accept-Encoding: invalid"
105 rxresp
106 expect resp.status == 200
107 expect resp.http.vary == "<undef>"
108 expect resp.bodylen == 100
109
110 txreq -url "/plain/accept-encoding-null"
111 rxresp
112 expect resp.status == 200
113 expect resp.http.vary == "<undef>"
114 expect resp.bodylen == 100
115
116 txreq -url "/html/accept-encoding-gzip" \
117 -hdr "Accept-Encoding: gzip"
118 rxresp
119 expect resp.status == 200
120 expect resp.http.vary == "<undef>"
121 expect resp.bodylen == 100
122
123 txreq -url "/html/accept-encoding-invalid" \
124 -hdr "Accept-Encoding: invalid"
125 rxresp
126 expect resp.status == 200
127 expect resp.http.vary == "<undef>"
128 expect resp.bodylen == 100
129
130 txreq -url "/html/accept-encoding-null"
131 rxresp
132 expect resp.status == 200
133 expect resp.http.vary == "<undef>"
134 expect resp.bodylen == 100
135
136 txreq -url "/dup-etag/accept-encoding-gzip" \
137 -hdr "Accept-Encoding: gzip"
138 rxresp
139 expect resp.status == 200
140 expect resp.http.vary == "<undef>"
141 expect resp.bodylen == 100
142} -run
143
144# This Client duplicates c1, against the "nothing" frontend, ensuring no Vary header is ever set.
145client c2 -connect ${h1_fe_nothing_sock} {
146 txreq -url "/plain/accept-encoding-gzip" \
147 -hdr "Accept-Encoding: gzip"
148 rxresp
149 expect resp.status == 200
150 expect resp.http.vary == "<undef>"
151 expect resp.bodylen == 100
152
153 txreq -url "/plain/accept-encoding-invalid" \
154 -hdr "Accept-Encoding: invalid"
155 rxresp
156 expect resp.status == 200
157 expect resp.http.vary == "<undef>"
158 expect resp.bodylen == 100
159
160 txreq -url "/plain/accept-encoding-null"
161 rxresp
162 expect resp.status == 200
163 expect resp.http.vary == "<undef>"
164 expect resp.bodylen == 100
165
166 txreq -url "/html/accept-encoding-gzip" \
167 -hdr "Accept-Encoding: gzip"
168 rxresp
169 expect resp.status == 200
170 expect resp.http.vary == "<undef>"
171 expect resp.bodylen == 100
172
173 txreq -url "/html/accept-encoding-invalid" \
174 -hdr "Accept-Encoding: invalid"
175 rxresp
176 expect resp.status == 200
177 expect resp.http.vary == "<undef>"
178 expect resp.bodylen == 100
179
180 txreq -url "/html/accept-encoding-null"
181 rxresp
182 expect resp.status == 200
183 expect resp.http.vary == "<undef>"
184 expect resp.bodylen == 100
185
186 txreq -url "/dup-etag/accept-encoding-gzip" \
187 -hdr "Accept-Encoding: gzip"
188 rxresp
189 expect resp.status == 200
190 expect resp.http.vary == "<undef>"
191 expect resp.bodylen == 100
192} -run