blob: b24cfd66607e4e233a45232c584e98006b67eeaa [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
Remi Tricot-Le Breton72cffaf2020-12-03 18:19:31 +010028 timeout connect 1s
29 timeout client 1s
30 timeout server 1s
31
32 frontend fe
33 bind "fd@${fe}"
34 default_backend test
35
36 backend test
37 http-request cache-use my_cache
38 server www ${s1_addr}:${s1_port}
39 http-response cache-store my_cache
40 http-response set-header X-Cache-Hit %[res.cache_hit]
41
42 cache my_cache
43 total-max-size 3
44 max-age 20
45 max-object-size 3072
46} -start
47
48
49client c1 -connect ${h1_fe_sock} {
50 txreq -url "/cached"
51 rxresp
52 expect resp.status == 200
53 expect resp.bodylen == 150
54
55 txreq -method "POST" -url "/cached" -bodylen 100
56 rxresp
57 expect resp.status == 200
58 expect resp.http.X-Cache-Hit == 0
59
60 txreq -url "/cached"
61 rxresp
62 expect resp.status == 200
63 expect resp.bodylen == 100
64 expect resp.http.X-Cache-Hit == 0
65} -run