blob: bc7d67b41d2b13a7de224b37c23369ffa2f29e5a [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 {
Willy Tarreaue1465c12021-05-09 14:41:41 +020028 global
29 # WT: limit false-positives causing "HTTP header incomplete" due to
30 # idle server connections being randomly used and randomly expiring
31 # under us.
32 tune.idle-pool.shared off
33
Remi Tricot-Le Breton5bbdc812020-10-22 10:40:06 +020034 defaults
35 mode http
36 ${no-htx} option http-use-htx
37 timeout connect 1s
38 timeout client 1s
39 timeout server 1s
40
41 frontend fe
42 bind "fd@${fe}"
43 default_backend test
44
45 backend test
46 http-request cache-use my_cache
47 server www ${s1_addr}:${s1_port}
48 http-response cache-store my_cache
49
Christopher Faulet7c647672022-11-16 17:19:42 +010050 # Remove Transfer-Encoding header because of a vtest issue with
51 # 304-Not-Modified responses
52 http-after-response del-header transfer-encoding if { status eq 304 }
53
Remi Tricot-Le Breton5bbdc812020-10-22 10:40:06 +020054 cache my_cache
55 total-max-size 3
56 max-age 20
57 max-object-size 3072
58} -start
59
60
61client c1 -connect ${h1_fe_sock} {
62 txreq
63 rxresp
64 expect resp.status == 200
65 expect resp.bodylen == 609
66 txreq
67 rxresp
68 expect resp.status == 200
69 expect resp.bodylen == 609
70 txreq \
71 -hdr "if-none-match: *"
72 rxresp
73 expect resp.status == 304
74 txreq \
75 -hdr "if-none-match: \"etag\""
76 rxresp
77 expect resp.status == 304
78 txreq \
79 -hdr "if-none-match: W/\"etag\""
80 rxresp
81 expect resp.status == 304
82} -run
83
84client c2 -connect ${h1_fe_sock} {
85 txreq \
86 -hdr "if-none-match: \"wrong_etag\""
87 rxresp
88 expect resp.status == 200
89 expect resp.bodylen == 609
90 txreq \
91 -hdr "if-none-match: W/\"wrong_etag\", W/\"etag\""
92 rxresp
93 expect resp.status == 304
94} -run