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 |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame] | 28 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
| 29 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 30 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
Remi Tricot-Le Breton | 72cffaf | 2020-12-03 18:19:31 +0100 | [diff] [blame] | 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 | |
| 49 | client 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 |