Christopher Faulet | 8f16148 | 2018-12-19 11:49:39 +0100 | [diff] [blame] | 1 | varnishtest "HTTP request tests: H2 to H1 (HTX and legacy mode)" |
Willy Tarreau | 7b8d203 | 2018-12-13 19:35:29 +0100 | [diff] [blame] | 2 | #REQUIRE_VERSION=1.9 |
| 3 | |
| 4 | # Run it with HAPROXY_PROGRAM=$PWD/haproxy varnishtest -l -k -t 1 "$1" |
| 5 | |
| 6 | feature ignore_unknown_macro |
| 7 | |
| 8 | # synchronize requests between streams |
| 9 | barrier b1 cond 2 -cyclic |
| 10 | barrier b2 cond 2 -cyclic |
| 11 | barrier b3 cond 2 -cyclic |
| 12 | barrier b4 cond 2 -cyclic |
| 13 | |
| 14 | server s1 { |
| 15 | rxreq |
| 16 | txresp \ |
| 17 | -status 200 \ |
| 18 | -body "response 1" |
| 19 | |
| 20 | barrier b2 sync |
| 21 | rxreq |
| 22 | txresp \ |
| 23 | -status 200 \ |
| 24 | -body "response 2" |
| 25 | |
| 26 | barrier b3 sync |
| 27 | rxreq |
| 28 | txresp \ |
| 29 | -status 200 \ |
| 30 | -body "response 3" |
| 31 | |
| 32 | barrier b4 sync |
Willy Tarreau | 1915ca2 | 2019-01-24 11:49:37 +0100 | [diff] [blame] | 33 | # the next request is never received |
Willy Tarreau | 7b8d203 | 2018-12-13 19:35:29 +0100 | [diff] [blame] | 34 | } -repeat 2 -start |
| 35 | |
| 36 | haproxy h1 -conf { |
Willy Tarreau | e1465c1 | 2021-05-09 14:41:41 +0200 | [diff] [blame] | 37 | global |
| 38 | # WT: limit false-positives causing "HTTP header incomplete" due to |
| 39 | # idle server connections being randomly used and randomly expiring |
| 40 | # under us. |
| 41 | tune.idle-pool.shared off |
| 42 | |
Willy Tarreau | 7b8d203 | 2018-12-13 19:35:29 +0100 | [diff] [blame] | 43 | defaults |
| 44 | #log stdout format raw daemon |
| 45 | mode http |
Willy Tarreau | 4a7b5b3 | 2018-12-14 09:51:48 +0100 | [diff] [blame] | 46 | option http-buffer-request |
Christopher Faulet | 8f16148 | 2018-12-19 11:49:39 +0100 | [diff] [blame] | 47 | ${no-htx} option http-use-htx |
Willy Tarreau | 7b8d203 | 2018-12-13 19:35:29 +0100 | [diff] [blame] | 48 | timeout connect 1s |
| 49 | timeout client 1s |
| 50 | timeout server 1s |
| 51 | |
| 52 | listen feh1 |
| 53 | bind "fd@${feh1}" |
| 54 | bind "fd@${feh2}" proto h2 |
| 55 | server s1 ${s1_addr}:${s1_port} |
| 56 | } -start |
| 57 | |
| 58 | client c1h2 -connect ${h1_feh2_sock} { |
| 59 | txpri |
| 60 | stream 0 { |
| 61 | txsettings |
| 62 | rxsettings |
| 63 | txsettings -ack |
Willy Tarreau | 7b8d203 | 2018-12-13 19:35:29 +0100 | [diff] [blame] | 64 | rxsettings |
| 65 | expect settings.ack == true |
| 66 | } -run |
| 67 | |
| 68 | # first request is valid |
| 69 | stream 1 { |
| 70 | txreq \ |
| 71 | -req "GET" \ |
| 72 | -scheme "https" \ |
| 73 | -url "/test1.html" |
| 74 | rxhdrs |
| 75 | expect resp.status == 200 |
| 76 | rxdata -all |
| 77 | expect resp.body == "response 1" |
| 78 | } -run |
| 79 | |
| 80 | # second request is valid and advertises C-L:0 |
| 81 | stream 3 { |
| 82 | barrier b2 sync |
| 83 | txreq \ |
| 84 | -req "GET" \ |
| 85 | -scheme "https" \ |
| 86 | -url "/test2.html" \ |
| 87 | -hdr "content-length" "0" |
| 88 | rxhdrs |
| 89 | expect resp.status == 200 |
| 90 | rxdata -all |
| 91 | expect resp.body == "response 2" |
| 92 | } -run |
| 93 | |
| 94 | # third request sends a body with a GET |
| 95 | stream 5 { |
| 96 | barrier b3 sync |
| 97 | txreq \ |
| 98 | -req "GET" \ |
| 99 | -scheme "https" \ |
| 100 | -url "/test3.html" \ |
| 101 | -nostrend \ |
| 102 | -body "this must be delivered, like it or not" |
| 103 | rxwinup |
| 104 | rxhdrs |
| 105 | expect resp.status == 200 |
| 106 | rxdata -all |
| 107 | expect resp.body == "response 3" |
| 108 | } -run |
| 109 | |
Willy Tarreau | 1915ca2 | 2019-01-24 11:49:37 +0100 | [diff] [blame] | 110 | # fourth request is valid and advertises C-L:2, and close, and is |
| 111 | # followed by a string "this is not sent\r\n\r\n" which causes a |
| 112 | # stream error of type PROTOCOL_ERROR. |
Willy Tarreau | 7b8d203 | 2018-12-13 19:35:29 +0100 | [diff] [blame] | 113 | stream 7 { |
| 114 | barrier b4 sync |
| 115 | txreq \ |
| 116 | -req "GET" \ |
| 117 | -scheme "https" \ |
| 118 | -url "/test4.html" \ |
Willy Tarreau | 1915ca2 | 2019-01-24 11:49:37 +0100 | [diff] [blame] | 119 | -hdr "content-length" "2" \ |
Willy Tarreau | 7b8d203 | 2018-12-13 19:35:29 +0100 | [diff] [blame] | 120 | -nostrend |
| 121 | txdata -data "this is sent and ignored" |
Willy Tarreau | 1915ca2 | 2019-01-24 11:49:37 +0100 | [diff] [blame] | 122 | rxrst |
Willy Tarreau | 7b8d203 | 2018-12-13 19:35:29 +0100 | [diff] [blame] | 123 | } -run |
| 124 | } -run |
| 125 | |
| 126 | # HEAD requests : don't work well yet |
| 127 | #client c2h2 -connect ${h1_feh2_sock} { |
| 128 | # txpri |
| 129 | # stream 0 { |
| 130 | # txsettings |
| 131 | # rxsettings |
| 132 | # txsettings -ack |
Willy Tarreau | 7b8d203 | 2018-12-13 19:35:29 +0100 | [diff] [blame] | 133 | # rxsettings |
| 134 | # expect settings.ack == true |
| 135 | # } -run |
| 136 | # |
| 137 | # # first request is valid |
| 138 | # stream 1 { |
| 139 | # txreq \ |
| 140 | # -req "HEAD" \ |
| 141 | # -scheme "https" \ |
| 142 | # -url "/test11.html" |
| 143 | # rxhdrs |
| 144 | # expect resp.status == 200 |
| 145 | # rxdata -all |
| 146 | # expect resp.bodylen == 0 |
| 147 | # } -run |
| 148 | # |
| 149 | # # second request is valid and advertises C-L:0 |
| 150 | # stream 3 { |
| 151 | # barrier b2 sync |
| 152 | # txreq \ |
| 153 | # -req "HEAD" \ |
| 154 | # -scheme "https" \ |
| 155 | # -url "/test12.html" \ |
| 156 | # -hdr "content-length" "0" |
| 157 | # rxhdrs |
| 158 | # expect resp.status == 200 |
| 159 | # rxdata -all |
| 160 | # expect resp.bodylen == 0 |
| 161 | # } -run |
| 162 | # |
| 163 | # # third request sends a body with a GET |
| 164 | # stream 5 { |
| 165 | # barrier b3 sync |
| 166 | # txreq \ |
| 167 | # -req "HEAD" \ |
| 168 | # -scheme "https" \ |
| 169 | # -url "/test13.html" \ |
| 170 | # -nostrend \ |
| 171 | # -body "this must be delivered, like it or not" |
| 172 | # rxwinup |
| 173 | # rxhdrs |
| 174 | # expect resp.status == 200 |
| 175 | # rxdata -all |
| 176 | # expect resp.bodylen == 0 |
| 177 | # } -run |
| 178 | # |
| 179 | # # fourth request is valid and advertises C-L:0, and close, and is |
| 180 | # # followed by a string "this is not sent\r\n\r\n" which must be |
| 181 | # # dropped. |
| 182 | # stream 7 { |
| 183 | # barrier b4 sync |
| 184 | # txreq \ |
| 185 | # -req "HEAD" \ |
| 186 | # -scheme "https" \ |
| 187 | # -url "/test14.html" \ |
| 188 | # -hdr "content-length" "0" \ |
| 189 | # -nostrend |
| 190 | # txdata -data "this is sent and ignored" |
| 191 | # rxwinup |
| 192 | # rxhdrs |
| 193 | # expect resp.status == 200 |
| 194 | # rxdata -all |
| 195 | # expect resp.bodylen == 0 |
| 196 | # } -run |
| 197 | #} -run |
| 198 | |
| 199 | # POST requests |
| 200 | client c3h2 -connect ${h1_feh2_sock} { |
| 201 | txpri |
| 202 | stream 0 { |
| 203 | txsettings |
| 204 | rxsettings |
| 205 | txsettings -ack |
Willy Tarreau | 7b8d203 | 2018-12-13 19:35:29 +0100 | [diff] [blame] | 206 | rxsettings |
| 207 | expect settings.ack == true |
| 208 | } -run |
| 209 | |
| 210 | # first request is valid |
| 211 | stream 1 { |
| 212 | txreq \ |
| 213 | -req "POST" \ |
| 214 | -scheme "https" \ |
| 215 | -url "/test21.html" |
| 216 | rxhdrs |
| 217 | expect resp.status == 200 |
| 218 | rxdata -all |
| 219 | expect resp.body == "response 1" |
| 220 | } -run |
| 221 | |
| 222 | # second request is valid and advertises C-L:0 |
| 223 | stream 3 { |
| 224 | barrier b2 sync |
| 225 | txreq \ |
| 226 | -req "POST" \ |
| 227 | -scheme "https" \ |
| 228 | -url "/test22.html" \ |
| 229 | -hdr "content-length" "0" |
| 230 | rxhdrs |
| 231 | expect resp.status == 200 |
| 232 | rxdata -all |
| 233 | expect resp.body == "response 2" |
| 234 | } -run |
| 235 | |
| 236 | # third request sends a body with a GET |
| 237 | stream 5 { |
| 238 | barrier b3 sync |
| 239 | txreq \ |
| 240 | -req "POST" \ |
| 241 | -scheme "https" \ |
| 242 | -url "/test23.html" \ |
| 243 | -nostrend \ |
| 244 | -body "this must be delivered, like it or not" |
| 245 | rxwinup |
| 246 | rxhdrs |
| 247 | expect resp.status == 200 |
| 248 | rxdata -all |
| 249 | expect resp.body == "response 3" |
| 250 | } -run |
| 251 | |
Willy Tarreau | 1915ca2 | 2019-01-24 11:49:37 +0100 | [diff] [blame] | 252 | # fourth request is valid and advertises C-L:2, and close, and is |
| 253 | # followed by a string "this is not sent\r\n\r\n" which results |
| 254 | # in a stream error. |
Willy Tarreau | 7b8d203 | 2018-12-13 19:35:29 +0100 | [diff] [blame] | 255 | stream 7 { |
| 256 | barrier b4 sync |
| 257 | txreq \ |
| 258 | -req "POST" \ |
| 259 | -scheme "https" \ |
| 260 | -url "/test24.html" \ |
Willy Tarreau | 1915ca2 | 2019-01-24 11:49:37 +0100 | [diff] [blame] | 261 | -hdr "content-length" "2" \ |
Willy Tarreau | 7b8d203 | 2018-12-13 19:35:29 +0100 | [diff] [blame] | 262 | -nostrend |
| 263 | txdata -data "this is sent and ignored" |
Willy Tarreau | 1915ca2 | 2019-01-24 11:49:37 +0100 | [diff] [blame] | 264 | rxrst |
Willy Tarreau | 7b8d203 | 2018-12-13 19:35:29 +0100 | [diff] [blame] | 265 | } -run |
| 266 | } -run |