Tim Duesterhus | 721d686 | 2019-06-17 16:10:07 +0200 | [diff] [blame] | 1 | varnishtest "Compression sets Vary header" |
| 2 | |
Tim Duesterhus | 721d686 | 2019-06-17 16:10:07 +0200 | [diff] [blame] | 3 | #REQUIRE_OPTION=ZLIB|SLZ |
| 4 | |
| 5 | feature ignore_unknown_macro |
| 6 | |
| 7 | server s1 { |
| 8 | rxreq |
| 9 | expect req.url == "/plain/accept-encoding-gzip" |
| 10 | expect req.http.accept-encoding == "gzip" |
| 11 | txresp \ |
| 12 | -hdr "Content-Type: text/plain" \ |
| 13 | -bodylen 100 |
| 14 | |
| 15 | rxreq |
| 16 | expect req.url == "/plain/accept-encoding-invalid" |
| 17 | expect req.http.accept-encoding == "invalid" |
| 18 | txresp \ |
| 19 | -hdr "Content-Type: text/plain" \ |
| 20 | -bodylen 100 |
| 21 | |
| 22 | rxreq |
| 23 | expect req.url == "/plain/accept-encoding-null" |
| 24 | expect req.http.accept-encoding == "<undef>" |
| 25 | txresp \ |
| 26 | -hdr "Content-Type: text/plain" \ |
| 27 | -bodylen 100 |
| 28 | |
| 29 | rxreq |
| 30 | expect req.url == "/html/accept-encoding-gzip" |
| 31 | expect req.http.accept-encoding == "gzip" |
| 32 | txresp \ |
| 33 | -hdr "Content-Type: text/html" \ |
| 34 | -bodylen 100 |
| 35 | |
| 36 | rxreq |
| 37 | expect req.url == "/html/accept-encoding-invalid" |
| 38 | expect req.http.accept-encoding == "invalid" |
| 39 | txresp \ |
| 40 | -hdr "Content-Type: text/html" \ |
| 41 | -bodylen 100 |
| 42 | |
| 43 | |
| 44 | rxreq |
| 45 | expect req.url == "/html/accept-encoding-null" |
| 46 | expect req.http.accept-encoding == "<undef>" |
| 47 | txresp \ |
| 48 | -hdr "Content-Type: text/html" \ |
| 49 | -bodylen 100 |
| 50 | |
| 51 | rxreq |
| 52 | expect req.url == "/dup-etag/accept-encoding-gzip" |
| 53 | expect req.http.accept-encoding == "gzip" |
| 54 | txresp \ |
| 55 | -hdr "Content-Type: text/plain" \ |
| 56 | -hdr "ETag: \"123\"" \ |
| 57 | -hdr "ETag: \"123\"" \ |
| 58 | -bodylen 100 |
| 59 | } -repeat 2 -start |
| 60 | |
| 61 | |
Christopher Faulet | 535dd92 | 2023-05-25 11:18:21 +0200 | [diff] [blame] | 62 | server s2 { |
| 63 | rxreq |
| 64 | expect req.url == "/vary/no-vary" |
| 65 | expect req.http.accept-encoding == "gzip" |
| 66 | txresp \ |
| 67 | -hdr "Content-Type: text/plain" \ |
| 68 | -bodylen 100 |
| 69 | |
| 70 | rxreq |
| 71 | expect req.url == "/vary/accept-encoding" |
| 72 | expect req.http.accept-encoding == "gzip" |
| 73 | txresp \ |
| 74 | -hdr "Content-Type: text/plain" \ |
| 75 | -hdr "Vary: Accept-Encoding" \ |
| 76 | -bodylen 100 |
| 77 | |
| 78 | rxreq |
| 79 | expect req.url == "/vary/other" |
| 80 | expect req.http.accept-encoding == "gzip" |
| 81 | txresp \ |
| 82 | -hdr "Content-Type: text/plain" \ |
| 83 | -hdr "Vary: Other" \ |
| 84 | -bodylen 100 |
| 85 | |
| 86 | rxreq |
| 87 | expect req.url == "/vary/accept-encoding-and-other" |
| 88 | expect req.http.accept-encoding == "gzip" |
| 89 | txresp \ |
| 90 | -hdr "Content-Type: text/plain" \ |
| 91 | -hdr "Vary: Accept-Encoding,Other" \ |
| 92 | -bodylen 100 |
| 93 | |
| 94 | rxreq |
| 95 | expect req.url == "/vary/other-and-accept-encoding" |
| 96 | expect req.http.accept-encoding == "gzip" |
| 97 | txresp \ |
| 98 | -hdr "Content-Type: text/plain" \ |
| 99 | -hdr "Vary: Other,Accept-Encoding" \ |
| 100 | -bodylen 100 |
| 101 | |
| 102 | rxreq |
| 103 | expect req.url == "/vary/empty" |
| 104 | expect req.http.accept-encoding == "gzip" |
| 105 | txresp \ |
| 106 | -hdr "Content-Type: text/plain" \ |
| 107 | -hdr "Vary: " \ |
| 108 | -bodylen 100 |
| 109 | } -start |
| 110 | |
| 111 | |
Tim Duesterhus | 721d686 | 2019-06-17 16:10:07 +0200 | [diff] [blame] | 112 | haproxy h1 -conf { |
Willy Tarreau | e1465c1 | 2021-05-09 14:41:41 +0200 | [diff] [blame] | 113 | global |
| 114 | # WT: limit false-positives causing "HTTP header incomplete" due to |
| 115 | # idle server connections being randomly used and randomly expiring |
| 116 | # under us. |
| 117 | tune.idle-pool.shared off |
| 118 | |
Tim Duesterhus | 721d686 | 2019-06-17 16:10:07 +0200 | [diff] [blame] | 119 | defaults |
| 120 | mode http |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame] | 121 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
| 122 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 123 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
Tim Duesterhus | 721d686 | 2019-06-17 16:10:07 +0200 | [diff] [blame] | 124 | |
| 125 | frontend fe-gzip |
| 126 | bind "fd@${fe_gzip}" |
| 127 | default_backend be-gzip |
| 128 | |
| 129 | backend be-gzip |
| 130 | compression algo gzip |
| 131 | compression type text/plain |
| 132 | server www ${s1_addr}:${s1_port} |
| 133 | |
| 134 | frontend fe-nothing |
| 135 | bind "fd@${fe_nothing}" |
| 136 | default_backend be-nothing |
| 137 | |
| 138 | backend be-nothing |
| 139 | server www ${s1_addr}:${s1_port} |
Christopher Faulet | 535dd92 | 2023-05-25 11:18:21 +0200 | [diff] [blame] | 140 | |
| 141 | frontend fe-vary |
| 142 | bind "fd@${fe_vary}" |
| 143 | default_backend be-vary |
| 144 | |
| 145 | backend be-vary |
| 146 | compression algo gzip |
| 147 | compression type text/plain |
| 148 | server www ${s2_addr}:${s2_port} |
| 149 | |
Tim Duesterhus | 721d686 | 2019-06-17 16:10:07 +0200 | [diff] [blame] | 150 | } -start |
| 151 | |
| 152 | client c1 -connect ${h1_fe_gzip_sock} { |
| 153 | txreq -url "/plain/accept-encoding-gzip" \ |
| 154 | -hdr "Accept-Encoding: gzip" |
| 155 | rxresp |
| 156 | expect resp.status == 200 |
| 157 | expect resp.http.content-encoding == "gzip" |
| 158 | expect resp.http.vary == "Accept-Encoding" |
| 159 | gunzip |
| 160 | expect resp.bodylen == 100 |
| 161 | |
| 162 | txreq -url "/plain/accept-encoding-invalid" \ |
| 163 | -hdr "Accept-Encoding: invalid" |
| 164 | rxresp |
| 165 | expect resp.status == 200 |
| 166 | expect resp.http.vary == "<undef>" |
| 167 | expect resp.bodylen == 100 |
| 168 | |
| 169 | txreq -url "/plain/accept-encoding-null" |
| 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-gzip" \ |
| 176 | -hdr "Accept-Encoding: gzip" |
| 177 | rxresp |
| 178 | expect resp.status == 200 |
| 179 | expect resp.http.vary == "<undef>" |
| 180 | expect resp.bodylen == 100 |
| 181 | |
| 182 | txreq -url "/html/accept-encoding-invalid" \ |
| 183 | -hdr "Accept-Encoding: invalid" |
| 184 | rxresp |
| 185 | expect resp.status == 200 |
| 186 | expect resp.http.vary == "<undef>" |
| 187 | expect resp.bodylen == 100 |
| 188 | |
| 189 | txreq -url "/html/accept-encoding-null" |
| 190 | rxresp |
| 191 | expect resp.status == 200 |
| 192 | expect resp.http.vary == "<undef>" |
| 193 | expect resp.bodylen == 100 |
| 194 | |
| 195 | txreq -url "/dup-etag/accept-encoding-gzip" \ |
| 196 | -hdr "Accept-Encoding: gzip" |
| 197 | rxresp |
| 198 | expect resp.status == 200 |
| 199 | expect resp.http.vary == "<undef>" |
| 200 | expect resp.bodylen == 100 |
| 201 | } -run |
| 202 | |
| 203 | # This Client duplicates c1, against the "nothing" frontend, ensuring no Vary header is ever set. |
| 204 | client c2 -connect ${h1_fe_nothing_sock} { |
| 205 | txreq -url "/plain/accept-encoding-gzip" \ |
| 206 | -hdr "Accept-Encoding: gzip" |
| 207 | rxresp |
| 208 | expect resp.status == 200 |
| 209 | expect resp.http.vary == "<undef>" |
| 210 | expect resp.bodylen == 100 |
| 211 | |
| 212 | txreq -url "/plain/accept-encoding-invalid" \ |
| 213 | -hdr "Accept-Encoding: invalid" |
| 214 | rxresp |
| 215 | expect resp.status == 200 |
| 216 | expect resp.http.vary == "<undef>" |
| 217 | expect resp.bodylen == 100 |
| 218 | |
| 219 | txreq -url "/plain/accept-encoding-null" |
| 220 | rxresp |
| 221 | expect resp.status == 200 |
| 222 | expect resp.http.vary == "<undef>" |
| 223 | expect resp.bodylen == 100 |
| 224 | |
| 225 | txreq -url "/html/accept-encoding-gzip" \ |
| 226 | -hdr "Accept-Encoding: gzip" |
| 227 | rxresp |
| 228 | expect resp.status == 200 |
| 229 | expect resp.http.vary == "<undef>" |
| 230 | expect resp.bodylen == 100 |
| 231 | |
| 232 | txreq -url "/html/accept-encoding-invalid" \ |
| 233 | -hdr "Accept-Encoding: invalid" |
| 234 | rxresp |
| 235 | expect resp.status == 200 |
| 236 | expect resp.http.vary == "<undef>" |
| 237 | expect resp.bodylen == 100 |
| 238 | |
| 239 | txreq -url "/html/accept-encoding-null" |
| 240 | rxresp |
| 241 | expect resp.status == 200 |
| 242 | expect resp.http.vary == "<undef>" |
| 243 | expect resp.bodylen == 100 |
| 244 | |
| 245 | txreq -url "/dup-etag/accept-encoding-gzip" \ |
| 246 | -hdr "Accept-Encoding: gzip" |
| 247 | rxresp |
| 248 | expect resp.status == 200 |
| 249 | expect resp.http.vary == "<undef>" |
| 250 | expect resp.bodylen == 100 |
| 251 | } -run |
Christopher Faulet | 535dd92 | 2023-05-25 11:18:21 +0200 | [diff] [blame] | 252 | |
| 253 | |
| 254 | client c3 -connect ${h1_fe_vary_sock} { |
| 255 | txreq -url "/vary/no-vary" \ |
| 256 | -hdr "Accept-Encoding: gzip" |
| 257 | rxresp |
| 258 | expect resp.status == 200 |
| 259 | expect resp.http.content-encoding == "gzip" |
| 260 | expect resp.http.vary == "Accept-Encoding" |
| 261 | gunzip |
| 262 | expect resp.bodylen == 100 |
| 263 | |
| 264 | txreq -url "/vary/accept-encoding" \ |
| 265 | -hdr "Accept-Encoding: gzip" |
| 266 | rxresp |
| 267 | expect resp.status == 200 |
| 268 | expect resp.http.content-encoding == "gzip" |
| 269 | expect resp.http.vary == "Accept-Encoding" |
| 270 | gunzip |
| 271 | expect resp.bodylen == 100 |
| 272 | |
| 273 | txreq -url "/vary/other" \ |
| 274 | -hdr "Accept-Encoding: gzip" |
| 275 | rxresp |
| 276 | expect resp.status == 200 |
| 277 | expect resp.http.content-encoding == "gzip" |
| 278 | expect resp.http.vary == "Other,Accept-Encoding" |
| 279 | gunzip |
| 280 | expect resp.bodylen == 100 |
| 281 | |
| 282 | txreq -url "/vary/accept-encoding-and-other" \ |
| 283 | -hdr "Accept-Encoding: gzip" |
| 284 | rxresp |
| 285 | expect resp.status == 200 |
| 286 | expect resp.http.content-encoding == "gzip" |
| 287 | expect resp.http.vary == "Accept-Encoding,Other" |
| 288 | gunzip |
| 289 | expect resp.bodylen == 100 |
| 290 | |
| 291 | txreq -url "/vary/other-and-accept-encoding" \ |
| 292 | -hdr "Accept-Encoding: gzip" |
| 293 | rxresp |
| 294 | expect resp.status == 200 |
| 295 | expect resp.http.content-encoding == "gzip" |
| 296 | expect resp.http.vary == "Other,Accept-Encoding" |
| 297 | gunzip |
| 298 | expect resp.bodylen == 100 |
| 299 | |
| 300 | txreq -url "/vary/empty" \ |
| 301 | -hdr "Accept-Encoding: gzip" |
| 302 | rxresp |
| 303 | expect resp.status == 200 |
| 304 | expect resp.http.content-encoding == "gzip" |
| 305 | expect resp.http.vary == "Accept-Encoding" |
| 306 | gunzip |
| 307 | expect resp.bodylen == 100 |
| 308 | } -run |