blob: c5391c90f9065f4e9a56d60f3709b98bb35203a7 [file] [log] [blame]
Remi Tricot-Le Breton5bbdc812020-10-22 10:40:06 +02001varnishtest "If-None-Match support"
2
3#REQUIRE_VERSION=2.3
4
5feature ignore_unknown_macro
6
7server s1 {
8 rxreq
9 txresp -nolen -hdr "Transfer-Encoding: chunked" \
10 -hdr "ETag: \"etag\""
11 chunkedlen 1
12 chunkedlen 1
13 chunkedlen 2
14 chunkedlen 3
15 chunkedlen 5
16 chunkedlen 8
17 chunkedlen 13
18 chunkedlen 21
19 chunkedlen 34
20 chunkedlen 55
21 chunkedlen 89
22 chunkedlen 144
23 chunkedlen 233
24 chunkedlen 0
25} -start
26
27haproxy h1 -conf {
28 defaults
29 mode http
30 ${no-htx} option http-use-htx
31 timeout connect 1s
32 timeout client 1s
33 timeout server 1s
34
35 frontend fe
36 bind "fd@${fe}"
37 default_backend test
38
39 backend test
40 http-request cache-use my_cache
41 server www ${s1_addr}:${s1_port}
42 http-response cache-store my_cache
43
44 cache my_cache
45 total-max-size 3
46 max-age 20
47 max-object-size 3072
48} -start
49
50
51client c1 -connect ${h1_fe_sock} {
52 txreq
53 rxresp
54 expect resp.status == 200
55 expect resp.bodylen == 609
56 txreq
57 rxresp
58 expect resp.status == 200
59 expect resp.bodylen == 609
60 txreq \
61 -hdr "if-none-match: *"
62 rxresp
63 expect resp.status == 304
64 txreq \
65 -hdr "if-none-match: \"etag\""
66 rxresp
67 expect resp.status == 304
68 txreq \
69 -hdr "if-none-match: W/\"etag\""
70 rxresp
71 expect resp.status == 304
72} -run
73
74client c2 -connect ${h1_fe_sock} {
75 txreq \
76 -hdr "if-none-match: \"wrong_etag\""
77 rxresp
78 expect resp.status == 200
79 expect resp.bodylen == 609
80 txreq \
81 -hdr "if-none-match: W/\"wrong_etag\", W/\"etag\""
82 rxresp
83 expect resp.status == 304
84} -run