Remi Tricot-Le Breton | 53161d8 | 2020-10-23 10:51:28 +0200 | [diff] [blame] | 1 | varnishtest "If-Modified-Since support" |
| 2 | |
| 3 | #REQUIRE_VERSION=2.3 |
| 4 | |
| 5 | feature ignore_unknown_macro |
| 6 | |
| 7 | server s1 { |
| 8 | # Response containing a "Last-Modified" field |
| 9 | rxreq |
| 10 | expect req.url == "/last_modified" |
| 11 | txresp -nolen -hdr "Transfer-Encoding: chunked" \ |
| 12 | -hdr "Last-Modified: Thu, 15 Oct 2020 22:23:24 GMT" |
| 13 | chunkedlen 15 |
| 14 | chunkedlen 15 |
| 15 | chunkedlen 15 |
| 16 | chunkedlen 0 |
| 17 | |
| 18 | # Response containing a "Date" field |
| 19 | rxreq |
| 20 | expect req.url == "/date" |
| 21 | txresp -nolen -hdr "Transfer-Encoding: chunked" \ |
Remi Tricot-Le Breton | 87c2f25 | 2020-11-12 11:14:41 +0100 | [diff] [blame] | 22 | -hdr "Date: Thu, 22 Oct 2020 16:51:12 GMT" \ |
| 23 | -hdr "Cache-Control: max-age=5" |
Remi Tricot-Le Breton | 53161d8 | 2020-10-23 10:51:28 +0200 | [diff] [blame] | 24 | chunkedlen 16 |
| 25 | chunkedlen 16 |
| 26 | chunkedlen 16 |
| 27 | chunkedlen 0 |
| 28 | |
| 29 | # Response containing both a "Last-Modified" and a "Date" fields |
| 30 | # Should behave the same way as if the "Date" field was not here. |
| 31 | rxreq |
| 32 | expect req.url == "/last_modified_and_date" |
| 33 | txresp -nolen -hdr "Transfer-Encoding: chunked" \ |
| 34 | -hdr "Last-Modified: Thu, 15 Oct 2020 14:24:38 GMT" \ |
| 35 | -hdr "Date: Thu, 22 Oct 2020 16:51:12 GMT" |
| 36 | chunkedlen 17 |
| 37 | chunkedlen 17 |
| 38 | chunkedlen 17 |
| 39 | chunkedlen 0 |
| 40 | } -start |
| 41 | |
| 42 | haproxy h1 -conf { |
| 43 | defaults |
| 44 | mode http |
| 45 | ${no-htx} option http-use-htx |
| 46 | timeout connect 1s |
| 47 | timeout client 1s |
| 48 | timeout server 1s |
| 49 | |
| 50 | frontend fe |
| 51 | bind "fd@${fe}" |
| 52 | default_backend test |
| 53 | |
| 54 | backend test |
| 55 | http-request cache-use my_cache |
| 56 | server www ${s1_addr}:${s1_port} |
| 57 | http-response cache-store my_cache |
| 58 | |
| 59 | cache my_cache |
| 60 | total-max-size 3 |
| 61 | max-age 20 |
| 62 | max-object-size 3072 |
| 63 | } -start |
| 64 | |
| 65 | |
| 66 | client c1 -connect ${h1_fe_sock} { |
| 67 | txreq -url "/last_modified" |
| 68 | rxresp |
| 69 | expect resp.status == 200 |
| 70 | expect resp.bodylen == 45 |
| 71 | |
| 72 | txreq -url "/date" |
| 73 | rxresp |
| 74 | expect resp.status == 200 |
| 75 | expect resp.bodylen == 48 |
| 76 | |
| 77 | txreq -url "/last_modified_and_date" |
| 78 | rxresp |
| 79 | expect resp.status == 200 |
| 80 | expect resp.bodylen == 51 |
| 81 | |
| 82 | |
| 83 | # Earlier date |
| 84 | # "Last-Modified" version |
| 85 | txreq -url "/last_modified" \ |
| 86 | -hdr "If-Modified-Since: Thu, 15 Oct 2020 00:00:01 GMT" |
| 87 | rxresp |
| 88 | expect resp.status == 200 |
| 89 | expect resp.bodylen == 45 |
| 90 | # "Date" version |
| 91 | txreq -url "/date" \ |
| 92 | -hdr "If-Modified-Since: Thu, 01 Oct 2020 00:00:01 GMT" |
| 93 | rxresp |
| 94 | expect resp.status == 200 |
| 95 | expect resp.bodylen == 48 |
| 96 | # "Last-Modified" and "Date" version |
| 97 | txreq -url "/last_modified_and_date" \ |
| 98 | -hdr "If-Modified-Since: Thu, 15 Oct 2020 00:00:01 GMT" |
| 99 | rxresp |
| 100 | expect resp.status == 200 |
| 101 | expect resp.bodylen == 51 |
| 102 | |
| 103 | |
| 104 | # Same date |
| 105 | # "Last-Modified" version |
| 106 | txreq -url "/last_modified" \ |
| 107 | -hdr "If-Modified-Since: Thu, 15 Oct 2020 22:23:24 GMT" |
| 108 | rxresp |
| 109 | expect resp.status == 304 |
| 110 | expect resp.bodylen == 0 |
| 111 | # "Date" version |
| 112 | txreq -url "/date" \ |
| 113 | -hdr "If-Modified-Since: Thu, 22 Oct 2020 16:51:12 GMT" |
| 114 | rxresp |
| 115 | expect resp.status == 304 |
| 116 | expect resp.bodylen == 0 |
| 117 | # "Last-Modified" and "Date" version |
| 118 | txreq -url "/last_modified_and_date" \ |
| 119 | -hdr "If-Modified-Since: Thu, 15 Oct 2020 16:51:12 GMT" |
| 120 | rxresp |
| 121 | expect resp.status == 304 |
| 122 | expect resp.bodylen == 0 |
| 123 | |
| 124 | |
| 125 | # Later date |
| 126 | # "Last-Modified" version |
| 127 | txreq -url "/last_modified" \ |
| 128 | -hdr "If-Modified-Since: Thu, 22 Oct 2020 23:00:00 GMT" |
| 129 | rxresp |
| 130 | expect resp.status == 304 |
| 131 | expect resp.bodylen == 0 |
| 132 | # "Date" version |
| 133 | txreq -url "/date" \ |
| 134 | -hdr "If-Modified-Since: Thu, 22 Oct 2020 23:00:00 GMT" |
| 135 | rxresp |
| 136 | expect resp.status == 304 |
| 137 | expect resp.bodylen == 0 |
| 138 | # "Last-Modified" and "Date" version |
| 139 | txreq -url "/last_modified_and_date" \ |
| 140 | -hdr "If-Modified-Since: Thu, 22 Oct 2020 23:00:00 GMT" |
| 141 | rxresp |
| 142 | expect resp.status == 304 |
| 143 | expect resp.bodylen == 0 |
| 144 | |
| 145 | } -run |
| 146 | |