Tim Duesterhus | 721d686 | 2019-06-17 16:10:07 +0200 | [diff] [blame] | 1 | varnishtest "Compression sets Vary header" |
| 2 | |
| 3 | #REQUIRE_VERSION=1.9 |
| 4 | #REQUIRE_OPTION=ZLIB|SLZ |
| 5 | |
| 6 | feature ignore_unknown_macro |
| 7 | |
| 8 | server s1 { |
| 9 | rxreq |
| 10 | expect req.url == "/plain/accept-encoding-gzip" |
| 11 | expect req.http.accept-encoding == "gzip" |
| 12 | txresp \ |
| 13 | -hdr "Content-Type: text/plain" \ |
| 14 | -bodylen 100 |
| 15 | |
| 16 | rxreq |
| 17 | expect req.url == "/plain/accept-encoding-invalid" |
| 18 | expect req.http.accept-encoding == "invalid" |
| 19 | txresp \ |
| 20 | -hdr "Content-Type: text/plain" \ |
| 21 | -bodylen 100 |
| 22 | |
| 23 | rxreq |
| 24 | expect req.url == "/plain/accept-encoding-null" |
| 25 | expect req.http.accept-encoding == "<undef>" |
| 26 | txresp \ |
| 27 | -hdr "Content-Type: text/plain" \ |
| 28 | -bodylen 100 |
| 29 | |
| 30 | rxreq |
| 31 | expect req.url == "/html/accept-encoding-gzip" |
| 32 | expect req.http.accept-encoding == "gzip" |
| 33 | txresp \ |
| 34 | -hdr "Content-Type: text/html" \ |
| 35 | -bodylen 100 |
| 36 | |
| 37 | rxreq |
| 38 | expect req.url == "/html/accept-encoding-invalid" |
| 39 | expect req.http.accept-encoding == "invalid" |
| 40 | txresp \ |
| 41 | -hdr "Content-Type: text/html" \ |
| 42 | -bodylen 100 |
| 43 | |
| 44 | |
| 45 | rxreq |
| 46 | expect req.url == "/html/accept-encoding-null" |
| 47 | expect req.http.accept-encoding == "<undef>" |
| 48 | txresp \ |
| 49 | -hdr "Content-Type: text/html" \ |
| 50 | -bodylen 100 |
| 51 | |
| 52 | rxreq |
| 53 | expect req.url == "/dup-etag/accept-encoding-gzip" |
| 54 | expect req.http.accept-encoding == "gzip" |
| 55 | txresp \ |
| 56 | -hdr "Content-Type: text/plain" \ |
| 57 | -hdr "ETag: \"123\"" \ |
| 58 | -hdr "ETag: \"123\"" \ |
| 59 | -bodylen 100 |
| 60 | } -repeat 2 -start |
| 61 | |
| 62 | |
| 63 | haproxy h1 -conf { |
Willy Tarreau | e1465c1 | 2021-05-09 14:41:41 +0200 | [diff] [blame^] | 64 | global |
| 65 | # WT: limit false-positives causing "HTTP header incomplete" due to |
| 66 | # idle server connections being randomly used and randomly expiring |
| 67 | # under us. |
| 68 | tune.idle-pool.shared off |
| 69 | |
Tim Duesterhus | 721d686 | 2019-06-17 16:10:07 +0200 | [diff] [blame] | 70 | defaults |
| 71 | mode http |
| 72 | ${no-htx} option http-use-htx |
| 73 | timeout connect 1s |
| 74 | timeout client 1s |
| 75 | timeout server 1s |
| 76 | |
| 77 | frontend fe-gzip |
| 78 | bind "fd@${fe_gzip}" |
| 79 | default_backend be-gzip |
| 80 | |
| 81 | backend be-gzip |
| 82 | compression algo gzip |
| 83 | compression type text/plain |
| 84 | server www ${s1_addr}:${s1_port} |
| 85 | |
| 86 | frontend fe-nothing |
| 87 | bind "fd@${fe_nothing}" |
| 88 | default_backend be-nothing |
| 89 | |
| 90 | backend be-nothing |
| 91 | server www ${s1_addr}:${s1_port} |
| 92 | } -start |
| 93 | |
| 94 | client c1 -connect ${h1_fe_gzip_sock} { |
| 95 | txreq -url "/plain/accept-encoding-gzip" \ |
| 96 | -hdr "Accept-Encoding: gzip" |
| 97 | rxresp |
| 98 | expect resp.status == 200 |
| 99 | expect resp.http.content-encoding == "gzip" |
| 100 | expect resp.http.vary == "Accept-Encoding" |
| 101 | gunzip |
| 102 | expect resp.bodylen == 100 |
| 103 | |
| 104 | txreq -url "/plain/accept-encoding-invalid" \ |
| 105 | -hdr "Accept-Encoding: invalid" |
| 106 | rxresp |
| 107 | expect resp.status == 200 |
| 108 | expect resp.http.vary == "<undef>" |
| 109 | expect resp.bodylen == 100 |
| 110 | |
| 111 | txreq -url "/plain/accept-encoding-null" |
| 112 | rxresp |
| 113 | expect resp.status == 200 |
| 114 | expect resp.http.vary == "<undef>" |
| 115 | expect resp.bodylen == 100 |
| 116 | |
| 117 | txreq -url "/html/accept-encoding-gzip" \ |
| 118 | -hdr "Accept-Encoding: gzip" |
| 119 | rxresp |
| 120 | expect resp.status == 200 |
| 121 | expect resp.http.vary == "<undef>" |
| 122 | expect resp.bodylen == 100 |
| 123 | |
| 124 | txreq -url "/html/accept-encoding-invalid" \ |
| 125 | -hdr "Accept-Encoding: invalid" |
| 126 | rxresp |
| 127 | expect resp.status == 200 |
| 128 | expect resp.http.vary == "<undef>" |
| 129 | expect resp.bodylen == 100 |
| 130 | |
| 131 | txreq -url "/html/accept-encoding-null" |
| 132 | rxresp |
| 133 | expect resp.status == 200 |
| 134 | expect resp.http.vary == "<undef>" |
| 135 | expect resp.bodylen == 100 |
| 136 | |
| 137 | txreq -url "/dup-etag/accept-encoding-gzip" \ |
| 138 | -hdr "Accept-Encoding: gzip" |
| 139 | rxresp |
| 140 | expect resp.status == 200 |
| 141 | expect resp.http.vary == "<undef>" |
| 142 | expect resp.bodylen == 100 |
| 143 | } -run |
| 144 | |
| 145 | # This Client duplicates c1, against the "nothing" frontend, ensuring no Vary header is ever set. |
| 146 | client c2 -connect ${h1_fe_nothing_sock} { |
| 147 | txreq -url "/plain/accept-encoding-gzip" \ |
| 148 | -hdr "Accept-Encoding: gzip" |
| 149 | rxresp |
| 150 | expect resp.status == 200 |
| 151 | expect resp.http.vary == "<undef>" |
| 152 | expect resp.bodylen == 100 |
| 153 | |
| 154 | txreq -url "/plain/accept-encoding-invalid" \ |
| 155 | -hdr "Accept-Encoding: invalid" |
| 156 | rxresp |
| 157 | expect resp.status == 200 |
| 158 | expect resp.http.vary == "<undef>" |
| 159 | expect resp.bodylen == 100 |
| 160 | |
| 161 | txreq -url "/plain/accept-encoding-null" |
| 162 | rxresp |
| 163 | expect resp.status == 200 |
| 164 | expect resp.http.vary == "<undef>" |
| 165 | expect resp.bodylen == 100 |
| 166 | |
| 167 | txreq -url "/html/accept-encoding-gzip" \ |
| 168 | -hdr "Accept-Encoding: gzip" |
| 169 | rxresp |
| 170 | expect resp.status == 200 |
| 171 | expect resp.http.vary == "<undef>" |
| 172 | expect resp.bodylen == 100 |
| 173 | |
| 174 | txreq -url "/html/accept-encoding-invalid" \ |
| 175 | -hdr "Accept-Encoding: invalid" |
| 176 | rxresp |
| 177 | expect resp.status == 200 |
| 178 | expect resp.http.vary == "<undef>" |
| 179 | expect resp.bodylen == 100 |
| 180 | |
| 181 | txreq -url "/html/accept-encoding-null" |
| 182 | rxresp |
| 183 | expect resp.status == 200 |
| 184 | expect resp.http.vary == "<undef>" |
| 185 | expect resp.bodylen == 100 |
| 186 | |
| 187 | txreq -url "/dup-etag/accept-encoding-gzip" \ |
| 188 | -hdr "Accept-Encoding: gzip" |
| 189 | rxresp |
| 190 | expect resp.status == 200 |
| 191 | expect resp.http.vary == "<undef>" |
| 192 | expect resp.bodylen == 100 |
| 193 | } -run |