Remi Tricot-Le Breton | 72cffaf | 2020-12-03 18:19:31 +0100 | [diff] [blame] | 1 | varnishtest "A successful unsafe method (POST for instance) on a cached entry must disable it." |
| 2 | |
Christopher Faulet | 85a8136 | 2020-12-15 17:13:39 +0100 | [diff] [blame] | 3 | #REQUIRE_VERSION=2.4 |
Remi Tricot-Le Breton | 72cffaf | 2020-12-03 18:19:31 +0100 | [diff] [blame] | 4 | |
| 5 | feature ignore_unknown_macro |
| 6 | |
| 7 | server 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 | |
| 25 | haproxy 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 | |
| 50 | client 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 |