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 |
Willy Tarreau | 7b8d203 | 2018-12-13 19:35:29 +0100 | [diff] [blame] | 47 | timeout connect 1s |
| 48 | timeout client 1s |
| 49 | timeout server 1s |
| 50 | |
| 51 | listen feh1 |
| 52 | bind "fd@${feh1}" |
| 53 | bind "fd@${feh2}" proto h2 |
| 54 | server s1 ${s1_addr}:${s1_port} |
| 55 | } -start |
| 56 | |
| 57 | client c1h2 -connect ${h1_feh2_sock} { |
| 58 | txpri |
| 59 | stream 0 { |
| 60 | txsettings |
| 61 | rxsettings |
| 62 | txsettings -ack |
Willy Tarreau | 7b8d203 | 2018-12-13 19:35:29 +0100 | [diff] [blame] | 63 | rxsettings |
| 64 | expect settings.ack == true |
| 65 | } -run |
| 66 | |
| 67 | # first request is valid |
| 68 | stream 1 { |
| 69 | txreq \ |
| 70 | -req "GET" \ |
| 71 | -scheme "https" \ |
| 72 | -url "/test1.html" |
| 73 | rxhdrs |
| 74 | expect resp.status == 200 |
| 75 | rxdata -all |
| 76 | expect resp.body == "response 1" |
| 77 | } -run |
| 78 | |
| 79 | # second request is valid and advertises C-L:0 |
| 80 | stream 3 { |
| 81 | barrier b2 sync |
| 82 | txreq \ |
| 83 | -req "GET" \ |
| 84 | -scheme "https" \ |
| 85 | -url "/test2.html" \ |
| 86 | -hdr "content-length" "0" |
| 87 | rxhdrs |
| 88 | expect resp.status == 200 |
| 89 | rxdata -all |
| 90 | expect resp.body == "response 2" |
| 91 | } -run |
| 92 | |
| 93 | # third request sends a body with a GET |
| 94 | stream 5 { |
| 95 | barrier b3 sync |
| 96 | txreq \ |
| 97 | -req "GET" \ |
| 98 | -scheme "https" \ |
| 99 | -url "/test3.html" \ |
| 100 | -nostrend \ |
| 101 | -body "this must be delivered, like it or not" |
| 102 | rxwinup |
| 103 | rxhdrs |
| 104 | expect resp.status == 200 |
| 105 | rxdata -all |
| 106 | expect resp.body == "response 3" |
| 107 | } -run |
| 108 | |
Willy Tarreau | 1915ca2 | 2019-01-24 11:49:37 +0100 | [diff] [blame] | 109 | # fourth request is valid and advertises C-L:2, and close, and is |
| 110 | # followed by a string "this is not sent\r\n\r\n" which causes a |
| 111 | # stream error of type PROTOCOL_ERROR. |
Willy Tarreau | 7b8d203 | 2018-12-13 19:35:29 +0100 | [diff] [blame] | 112 | stream 7 { |
| 113 | barrier b4 sync |
| 114 | txreq \ |
| 115 | -req "GET" \ |
| 116 | -scheme "https" \ |
| 117 | -url "/test4.html" \ |
Willy Tarreau | 1915ca2 | 2019-01-24 11:49:37 +0100 | [diff] [blame] | 118 | -hdr "content-length" "2" \ |
Willy Tarreau | 7b8d203 | 2018-12-13 19:35:29 +0100 | [diff] [blame] | 119 | -nostrend |
| 120 | txdata -data "this is sent and ignored" |
Willy Tarreau | 1915ca2 | 2019-01-24 11:49:37 +0100 | [diff] [blame] | 121 | rxrst |
Willy Tarreau | 7b8d203 | 2018-12-13 19:35:29 +0100 | [diff] [blame] | 122 | } -run |
| 123 | } -run |
| 124 | |
| 125 | # HEAD requests : don't work well yet |
| 126 | #client c2h2 -connect ${h1_feh2_sock} { |
| 127 | # txpri |
| 128 | # stream 0 { |
| 129 | # txsettings |
| 130 | # rxsettings |
| 131 | # txsettings -ack |
Willy Tarreau | 7b8d203 | 2018-12-13 19:35:29 +0100 | [diff] [blame] | 132 | # rxsettings |
| 133 | # expect settings.ack == true |
| 134 | # } -run |
| 135 | # |
| 136 | # # first request is valid |
| 137 | # stream 1 { |
| 138 | # txreq \ |
| 139 | # -req "HEAD" \ |
| 140 | # -scheme "https" \ |
| 141 | # -url "/test11.html" |
| 142 | # rxhdrs |
| 143 | # expect resp.status == 200 |
| 144 | # rxdata -all |
| 145 | # expect resp.bodylen == 0 |
| 146 | # } -run |
| 147 | # |
| 148 | # # second request is valid and advertises C-L:0 |
| 149 | # stream 3 { |
| 150 | # barrier b2 sync |
| 151 | # txreq \ |
| 152 | # -req "HEAD" \ |
| 153 | # -scheme "https" \ |
| 154 | # -url "/test12.html" \ |
| 155 | # -hdr "content-length" "0" |
| 156 | # rxhdrs |
| 157 | # expect resp.status == 200 |
| 158 | # rxdata -all |
| 159 | # expect resp.bodylen == 0 |
| 160 | # } -run |
| 161 | # |
| 162 | # # third request sends a body with a GET |
| 163 | # stream 5 { |
| 164 | # barrier b3 sync |
| 165 | # txreq \ |
| 166 | # -req "HEAD" \ |
| 167 | # -scheme "https" \ |
| 168 | # -url "/test13.html" \ |
| 169 | # -nostrend \ |
| 170 | # -body "this must be delivered, like it or not" |
| 171 | # rxwinup |
| 172 | # rxhdrs |
| 173 | # expect resp.status == 200 |
| 174 | # rxdata -all |
| 175 | # expect resp.bodylen == 0 |
| 176 | # } -run |
| 177 | # |
| 178 | # # fourth request is valid and advertises C-L:0, and close, and is |
| 179 | # # followed by a string "this is not sent\r\n\r\n" which must be |
| 180 | # # dropped. |
| 181 | # stream 7 { |
| 182 | # barrier b4 sync |
| 183 | # txreq \ |
| 184 | # -req "HEAD" \ |
| 185 | # -scheme "https" \ |
| 186 | # -url "/test14.html" \ |
| 187 | # -hdr "content-length" "0" \ |
| 188 | # -nostrend |
| 189 | # txdata -data "this is sent and ignored" |
| 190 | # rxwinup |
| 191 | # rxhdrs |
| 192 | # expect resp.status == 200 |
| 193 | # rxdata -all |
| 194 | # expect resp.bodylen == 0 |
| 195 | # } -run |
| 196 | #} -run |
| 197 | |
| 198 | # POST requests |
| 199 | client c3h2 -connect ${h1_feh2_sock} { |
| 200 | txpri |
| 201 | stream 0 { |
| 202 | txsettings |
| 203 | rxsettings |
| 204 | txsettings -ack |
Willy Tarreau | 7b8d203 | 2018-12-13 19:35:29 +0100 | [diff] [blame] | 205 | rxsettings |
| 206 | expect settings.ack == true |
| 207 | } -run |
| 208 | |
| 209 | # first request is valid |
| 210 | stream 1 { |
| 211 | txreq \ |
| 212 | -req "POST" \ |
| 213 | -scheme "https" \ |
| 214 | -url "/test21.html" |
| 215 | rxhdrs |
| 216 | expect resp.status == 200 |
| 217 | rxdata -all |
| 218 | expect resp.body == "response 1" |
| 219 | } -run |
| 220 | |
| 221 | # second request is valid and advertises C-L:0 |
| 222 | stream 3 { |
| 223 | barrier b2 sync |
| 224 | txreq \ |
| 225 | -req "POST" \ |
| 226 | -scheme "https" \ |
| 227 | -url "/test22.html" \ |
| 228 | -hdr "content-length" "0" |
| 229 | rxhdrs |
| 230 | expect resp.status == 200 |
| 231 | rxdata -all |
| 232 | expect resp.body == "response 2" |
| 233 | } -run |
| 234 | |
| 235 | # third request sends a body with a GET |
| 236 | stream 5 { |
| 237 | barrier b3 sync |
| 238 | txreq \ |
| 239 | -req "POST" \ |
| 240 | -scheme "https" \ |
| 241 | -url "/test23.html" \ |
| 242 | -nostrend \ |
| 243 | -body "this must be delivered, like it or not" |
| 244 | rxwinup |
| 245 | rxhdrs |
| 246 | expect resp.status == 200 |
| 247 | rxdata -all |
| 248 | expect resp.body == "response 3" |
| 249 | } -run |
| 250 | |
Willy Tarreau | 1915ca2 | 2019-01-24 11:49:37 +0100 | [diff] [blame] | 251 | # fourth request is valid and advertises C-L:2, and close, and is |
| 252 | # followed by a string "this is not sent\r\n\r\n" which results |
| 253 | # in a stream error. |
Willy Tarreau | 7b8d203 | 2018-12-13 19:35:29 +0100 | [diff] [blame] | 254 | stream 7 { |
| 255 | barrier b4 sync |
| 256 | txreq \ |
| 257 | -req "POST" \ |
| 258 | -scheme "https" \ |
| 259 | -url "/test24.html" \ |
Willy Tarreau | 1915ca2 | 2019-01-24 11:49:37 +0100 | [diff] [blame] | 260 | -hdr "content-length" "2" \ |
Willy Tarreau | 7b8d203 | 2018-12-13 19:35:29 +0100 | [diff] [blame] | 261 | -nostrend |
| 262 | txdata -data "this is sent and ignored" |
Willy Tarreau | 1915ca2 | 2019-01-24 11:49:37 +0100 | [diff] [blame] | 263 | rxrst |
Willy Tarreau | 7b8d203 | 2018-12-13 19:35:29 +0100 | [diff] [blame] | 264 | } -run |
| 265 | } -run |