summaryrefslogtreecommitdiffstats
path: root/reg-tests/compression/vary.vtc
blob: 8219c734e61c6013440e2a7fab1b4871885876bd (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
varnishtest "Compression sets Vary header"

#REQUIRE_VERSION=1.9
#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


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}
} -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