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