summaryrefslogtreecommitdiffstats
path: root/reg-tests/compression/vary.vtc
blob: 489de30f64f62f974c9eb2d43b3ce388854fa49f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
varnishtest "Compression sets Vary header"

#REQUIRE_OPTION=ZLIB|SLZ

feature ignore_unknown_macro

server s1 {
        rxreq
        expect req.url == "/plain/accept-encoding-gzip"
        expect req.http.accept-encoding == "gzip"
        txresp \
          -hdr "Content-Type: text/plain" \
          -bodylen 100

        rxreq
        expect req.url == "/plain/accept-encoding-invalid"
        expect req.http.accept-encoding == "invalid"
        txresp \
          -hdr "Content-Type: text/plain" \
          -bodylen 100

        rxreq
        expect req.url == "/plain/accept-encoding-null"
        expect req.http.accept-encoding == "<undef>"
        txresp \
          -hdr "Content-Type: text/plain" \
          -bodylen 100

        rxreq
        expect req.url == "/html/accept-encoding-gzip"
        expect req.http.accept-encoding == "gzip"
        txresp \
          -hdr "Content-Type: text/html" \
          -bodylen 100

        rxreq
        expect req.url == "/html/accept-encoding-invalid"
        expect req.http.accept-encoding == "invalid"
        txresp \
          -hdr "Content-Type: text/html" \
          -bodylen 100


        rxreq
        expect req.url == "/html/accept-encoding-null"
        expect req.http.accept-encoding == "<undef>"
        txresp \
          -hdr "Content-Type: text/html" \
          -bodylen 100

        rxreq
        expect req.url == "/dup-etag/accept-encoding-gzip"
        expect req.http.accept-encoding == "gzip"
        txresp \
          -hdr "Content-Type: text/plain" \
          -hdr "ETag: \"123\"" \
          -hdr "ETag: \"123\"" \
          -bodylen 100
} -repeat 2 -start


server s2 {
        rxreq
        expect req.url == "/vary/no-vary"
        expect req.http.accept-encoding == "gzip"
        txresp \
          -hdr "Content-Type: text/plain" \
          -bodylen 100

        rxreq
        expect req.url == "/vary/accept-encoding"
        expect req.http.accept-encoding == "gzip"
        txresp \
          -hdr "Content-Type: text/plain" \
          -hdr "Vary: Accept-Encoding" \
          -bodylen 100

        rxreq
        expect req.url == "/vary/other"
        expect req.http.accept-encoding == "gzip"
        txresp \
          -hdr "Content-Type: text/plain" \
          -hdr "Vary: Other" \
          -bodylen 100

        rxreq
        expect req.url == "/vary/accept-encoding-and-other"
        expect req.http.accept-encoding == "gzip"
        txresp \
          -hdr "Content-Type: text/plain" \
          -hdr "Vary: Accept-Encoding,Other" \
          -bodylen 100

        rxreq
        expect req.url == "/vary/other-and-accept-encoding"
        expect req.http.accept-encoding == "gzip"
        txresp \
          -hdr "Content-Type: text/plain" \
          -hdr "Vary: Other,Accept-Encoding" \
          -bodylen 100

        rxreq
        expect req.url == "/vary/empty"
        expect req.http.accept-encoding == "gzip"
        txresp \
          -hdr "Content-Type: text/plain" \
          -hdr "Vary: " \
          -bodylen 100
} -start


haproxy h1 -conf {
    global
        # WT: limit false-positives causing "HTTP header incomplete" due to
        # idle server connections being randomly used and randomly expiring
        # under us.
        tune.idle-pool.shared off

    defaults
        mode http
        timeout connect "${HAPROXY_TEST_TIMEOUT-5s}"
        timeout client  "${HAPROXY_TEST_TIMEOUT-5s}"
        timeout server  "${HAPROXY_TEST_TIMEOUT-5s}"

    frontend fe-gzip
        bind "fd@${fe_gzip}"
        default_backend be-gzip

    backend be-gzip
        compression algo gzip
        compression type text/plain
        server www ${s1_addr}:${s1_port}

    frontend fe-nothing
        bind "fd@${fe_nothing}"
        default_backend be-nothing

    backend be-nothing
        server www ${s1_addr}:${s1_port}

    frontend fe-vary
        bind "fd@${fe_vary}"
        default_backend be-vary

    backend be-vary
        compression algo gzip
        compression type text/plain
        server www ${s2_addr}:${s2_port}

} -start

client c1 -connect ${h1_fe_gzip_sock} {
        txreq -url "/plain/accept-encoding-gzip" \
          -hdr "Accept-Encoding: gzip"
        rxresp
        expect resp.status == 200
        expect resp.http.content-encoding == "gzip"
        expect resp.http.vary == "Accept-Encoding"
        gunzip
        expect resp.bodylen == 100

        txreq -url "/plain/accept-encoding-invalid" \
          -hdr "Accept-Encoding: invalid"
        rxresp
        expect resp.status == 200
        expect resp.http.vary == "<undef>"
        expect resp.bodylen == 100

        txreq -url "/plain/accept-encoding-null"
        rxresp
        expect resp.status == 200
        expect resp.http.vary == "<undef>"
        expect resp.bodylen == 100

        txreq -url "/html/accept-encoding-gzip" \
          -hdr "Accept-Encoding: gzip"
        rxresp
        expect resp.status == 200
        expect resp.http.vary == "<undef>"
        expect resp.bodylen == 100

        txreq -url "/html/accept-encoding-invalid" \
          -hdr "Accept-Encoding: invalid"
        rxresp
        expect resp.status == 200
        expect resp.http.vary == "<undef>"
        expect resp.bodylen == 100

        txreq -url "/html/accept-encoding-null"
        rxresp
        expect resp.status == 200
        expect resp.http.vary == "<undef>"
        expect resp.bodylen == 100

        txreq -url "/dup-etag/accept-encoding-gzip" \
          -hdr "Accept-Encoding: gzip"
        rxresp
        expect resp.status == 200
        expect resp.http.vary == "<undef>"
        expect resp.bodylen == 100
} -run

# This Client duplicates c1, against the "nothing" frontend, ensuring no Vary header is ever set.
client c2 -connect ${h1_fe_nothing_sock} {
        txreq -url "/plain/accept-encoding-gzip" \
          -hdr "Accept-Encoding: gzip"
        rxresp
        expect resp.status == 200
        expect resp.http.vary == "<undef>"
        expect resp.bodylen == 100

        txreq -url "/plain/accept-encoding-invalid" \
          -hdr "Accept-Encoding: invalid"
        rxresp
        expect resp.status == 200
        expect resp.http.vary == "<undef>"
        expect resp.bodylen == 100

        txreq -url "/plain/accept-encoding-null"
        rxresp
        expect resp.status == 200
        expect resp.http.vary == "<undef>"
        expect resp.bodylen == 100

        txreq -url "/html/accept-encoding-gzip" \
          -hdr "Accept-Encoding: gzip"
        rxresp
        expect resp.status == 200
        expect resp.http.vary == "<undef>"
        expect resp.bodylen == 100

        txreq -url "/html/accept-encoding-invalid" \
          -hdr "Accept-Encoding: invalid"
        rxresp
        expect resp.status == 200
        expect resp.http.vary == "<undef>"
        expect resp.bodylen == 100

        txreq -url "/html/accept-encoding-null"
        rxresp
        expect resp.status == 200
        expect resp.http.vary == "<undef>"
        expect resp.bodylen == 100

        txreq -url "/dup-etag/accept-encoding-gzip" \
          -hdr "Accept-Encoding: gzip"
        rxresp
        expect resp.status == 200
        expect resp.http.vary == "<undef>"
        expect resp.bodylen == 100
} -run


client c3 -connect ${h1_fe_vary_sock} {
        txreq -url "/vary/no-vary" \
          -hdr "Accept-Encoding: gzip"
        rxresp
        expect resp.status == 200
        expect resp.http.content-encoding == "gzip"
        expect resp.http.vary == "Accept-Encoding"
        gunzip
        expect resp.bodylen == 100

        txreq -url "/vary/accept-encoding" \
          -hdr "Accept-Encoding: gzip"
        rxresp
        expect resp.status == 200
        expect resp.http.content-encoding == "gzip"
        expect resp.http.vary == "Accept-Encoding"
        gunzip
        expect resp.bodylen == 100

        txreq -url "/vary/other" \
          -hdr "Accept-Encoding: gzip"
        rxresp
        expect resp.status == 200
        expect resp.http.content-encoding == "gzip"
        expect resp.http.vary == "Other,Accept-Encoding"
        gunzip
        expect resp.bodylen == 100

        txreq -url "/vary/accept-encoding-and-other" \
          -hdr "Accept-Encoding: gzip"
        rxresp
        expect resp.status == 200
        expect resp.http.content-encoding == "gzip"
        expect resp.http.vary == "Accept-Encoding,Other"
        gunzip
        expect resp.bodylen == 100

        txreq -url "/vary/other-and-accept-encoding" \
          -hdr "Accept-Encoding: gzip"
        rxresp
        expect resp.status == 200
        expect resp.http.content-encoding == "gzip"
        expect resp.http.vary == "Other,Accept-Encoding"
        gunzip
        expect resp.bodylen == 100

        txreq -url "/vary/empty" \
          -hdr "Accept-Encoding: gzip"
        rxresp
        expect resp.status == 200
        expect resp.http.content-encoding == "gzip"
        expect resp.http.vary == "Accept-Encoding"
        gunzip
        expect resp.bodylen == 100
} -run