blob: db6414ed40cca05128855730d9a55698148320eb [file] [log] [blame]
Remi Tricot-Le Breton72cffaf2020-12-03 18:19:31 +01001varnishtest "A successful unsafe method (POST for instance) on a cached entry must disable it."
2
Christopher Faulet85a81362020-12-15 17:13:39 +01003#REQUIRE_VERSION=2.4
Remi Tricot-Le Breton72cffaf2020-12-03 18:19:31 +01004
5feature ignore_unknown_macro
6
7server s1 {
8 rxreq
9 expect req.url == "/cached"
10 txresp -hdr "Cache-Control: max-age=5" \
11 -bodylen 150
12
13 rxreq
14 expect req.url == "/cached"
15 expect req.method == "POST"
16 txresp
17
18 rxreq
19 expect req.url == "/cached"
20 txresp -hdr "Cache-Control: max-age=5" \
21 -bodylen 100
22
23} -start
24
25haproxy h1 -conf {
26 defaults
27 mode http
28 ${no-htx} option http-use-htx
29 timeout connect 1s
30 timeout client 1s
31 timeout server 1s
32
33 frontend fe
34 bind "fd@${fe}"
35 default_backend test
36
37 backend test
38 http-request cache-use my_cache
39 server www ${s1_addr}:${s1_port}
40 http-response cache-store my_cache
41 http-response set-header X-Cache-Hit %[res.cache_hit]
42
43 cache my_cache
44 total-max-size 3
45 max-age 20
46 max-object-size 3072
47} -start
48
49
50client c1 -connect ${h1_fe_sock} {
51 txreq -url "/cached"
52 rxresp
53 expect resp.status == 200
54 expect resp.bodylen == 150
55
56 txreq -method "POST" -url "/cached" -bodylen 100
57 rxresp
58 expect resp.status == 200
59 expect resp.http.X-Cache-Hit == 0
60
61 txreq -url "/cached"
62 rxresp
63 expect resp.status == 200
64 expect resp.bodylen == 100
65 expect resp.http.X-Cache-Hit == 0
66} -run