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 | cc9bf2e | 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 { |
Willy Tarreau | e1465c1 | 2021-05-09 14:41:41 +0200 | [diff] [blame] | 43 | global |
| 44 | # WT: limit false-positives causing "HTTP header incomplete" due to |
| 45 | # idle server connections being randomly used and randomly expiring |
| 46 | # under us. |
| 47 | tune.idle-pool.shared off |
| 48 | |
Remi Tricot-Le Breton | 53161d8 | 2020-10-23 10:51:28 +0200 | [diff] [blame] | 49 | defaults |
| 50 | mode http |
Willy Tarreau | f673923 | 2021-11-18 17:46:22 +0100 | [diff] [blame] | 51 | timeout connect "${HAPROXY_TEST_TIMEOUT-5s}" |
| 52 | timeout client "${HAPROXY_TEST_TIMEOUT-5s}" |
| 53 | timeout server "${HAPROXY_TEST_TIMEOUT-5s}" |
Remi Tricot-Le Breton | 53161d8 | 2020-10-23 10:51:28 +0200 | [diff] [blame] | 54 | |
| 55 | frontend fe |
| 56 | bind "fd@${fe}" |
| 57 | default_backend test |
| 58 | |
| 59 | backend test |
| 60 | http-request cache-use my_cache |
| 61 | server www ${s1_addr}:${s1_port} |
| 62 | http-response cache-store my_cache |
| 63 | |
| 64 | cache my_cache |
| 65 | total-max-size 3 |
| 66 | max-age 20 |
| 67 | max-object-size 3072 |
| 68 | } -start |
| 69 | |
| 70 | |
| 71 | client c1 -connect ${h1_fe_sock} { |
| 72 | txreq -url "/last_modified" |
| 73 | rxresp |
| 74 | expect resp.status == 200 |
| 75 | expect resp.bodylen == 45 |
| 76 | |
| 77 | txreq -url "/date" |
| 78 | rxresp |
| 79 | expect resp.status == 200 |
| 80 | expect resp.bodylen == 48 |
| 81 | |
| 82 | txreq -url "/last_modified_and_date" |
| 83 | rxresp |
| 84 | expect resp.status == 200 |
| 85 | expect resp.bodylen == 51 |
| 86 | |
| 87 | |
| 88 | # Earlier date |
| 89 | # "Last-Modified" version |
| 90 | txreq -url "/last_modified" \ |
| 91 | -hdr "If-Modified-Since: Thu, 15 Oct 2020 00:00:01 GMT" |
| 92 | rxresp |
| 93 | expect resp.status == 200 |
| 94 | expect resp.bodylen == 45 |
| 95 | # "Date" version |
| 96 | txreq -url "/date" \ |
| 97 | -hdr "If-Modified-Since: Thu, 01 Oct 2020 00:00:01 GMT" |
| 98 | rxresp |
| 99 | expect resp.status == 200 |
| 100 | expect resp.bodylen == 48 |
| 101 | # "Last-Modified" and "Date" version |
| 102 | txreq -url "/last_modified_and_date" \ |
| 103 | -hdr "If-Modified-Since: Thu, 15 Oct 2020 00:00:01 GMT" |
| 104 | rxresp |
| 105 | expect resp.status == 200 |
| 106 | expect resp.bodylen == 51 |
| 107 | |
| 108 | |
| 109 | # Same date |
| 110 | # "Last-Modified" version |
| 111 | txreq -url "/last_modified" \ |
| 112 | -hdr "If-Modified-Since: Thu, 15 Oct 2020 22:23:24 GMT" |
| 113 | rxresp |
| 114 | expect resp.status == 304 |
| 115 | expect resp.bodylen == 0 |
| 116 | # "Date" version |
| 117 | txreq -url "/date" \ |
| 118 | -hdr "If-Modified-Since: Thu, 22 Oct 2020 16:51:12 GMT" |
| 119 | rxresp |
| 120 | expect resp.status == 304 |
| 121 | expect resp.bodylen == 0 |
| 122 | # "Last-Modified" and "Date" version |
| 123 | txreq -url "/last_modified_and_date" \ |
| 124 | -hdr "If-Modified-Since: Thu, 15 Oct 2020 16:51:12 GMT" |
| 125 | rxresp |
| 126 | expect resp.status == 304 |
| 127 | expect resp.bodylen == 0 |
| 128 | |
| 129 | |
| 130 | # Later date |
| 131 | # "Last-Modified" version |
| 132 | txreq -url "/last_modified" \ |
| 133 | -hdr "If-Modified-Since: Thu, 22 Oct 2020 23:00:00 GMT" |
| 134 | rxresp |
| 135 | expect resp.status == 304 |
| 136 | expect resp.bodylen == 0 |
| 137 | # "Date" version |
| 138 | txreq -url "/date" \ |
| 139 | -hdr "If-Modified-Since: Thu, 22 Oct 2020 23:00:00 GMT" |
| 140 | rxresp |
| 141 | expect resp.status == 304 |
| 142 | expect resp.bodylen == 0 |
| 143 | # "Last-Modified" and "Date" version |
| 144 | txreq -url "/last_modified_and_date" \ |
| 145 | -hdr "If-Modified-Since: Thu, 22 Oct 2020 23:00:00 GMT" |
| 146 | rxresp |
| 147 | expect resp.status == 304 |
| 148 | expect resp.bodylen == 0 |
| 149 | |
| 150 | } -run |
| 151 | |