Frédéric Lécaille | 02a1669 | 2018-12-21 11:56:26 +0100 | [diff] [blame] | 1 | varnishtest "A test for http-request-buffer option" |
| 2 | feature ignore_unknown_macro |
| 3 | |
Frédéric Lécaille | 02a1669 | 2018-12-21 11:56:26 +0100 | [diff] [blame] | 4 | |
| 5 | # This test checks HTTP request buffering feature. |
| 6 | # We run one server s1 which can serve only one client (no -repeat argument here). |
| 7 | # c1 client uses a malformed request which is not transferred to s1 server |
| 8 | # thanks to "http-buffer-request". If this was the case, c2 client |
| 9 | # could not connect to s1 server and this would lead to make this test fail. |
| 10 | |
| 11 | server s1 { |
| 12 | rxreq |
| 13 | expect req.bodylen == 257 |
| 14 | txresp |
| 15 | } -start |
| 16 | |
| 17 | syslog S -level info { |
| 18 | recv |
| 19 | expect ~ "[^:\\[ ]*\\[[0-9]*\\]: .* .* fe1 fe1/<NOSRV> .* 408 .* - - cD-- .* .* \"GET /this-is-a-long-url-this-is-a-long-url-this-is-a-long-url-this-is-a-long-url-this-is-a-long-url-this-is-a-long-url-this-is-a-long-url HTTP/1\\.1\"" |
| 20 | recv |
| 21 | expect ~ "[^:\\[ ]*\\[[0-9]*\\]: .* .* fe1 be1/srv1 [0-9]*/[0-9]*/[0-9]*/[0-9]*/[0-9]* 200 .* - - ---- .* .* \"GET / HTTP/1\\.1\"" |
| 22 | } -start |
| 23 | |
| 24 | haproxy h1 -conf { |
| 25 | defaults |
| 26 | mode http |
Frédéric Lécaille | 02a1669 | 2018-12-21 11:56:26 +0100 | [diff] [blame] | 27 | timeout client 100ms |
| 28 | timeout server 1s |
| 29 | timeout connect 1s |
| 30 | |
| 31 | backend be1 |
| 32 | server srv1 ${s1_addr}:${s1_port} |
| 33 | |
| 34 | frontend fe1 |
| 35 | option httplog |
| 36 | option http-buffer-request |
| 37 | log ${S_addr}:${S_port} local0 debug err |
| 38 | bind "fd@${fe1}" |
| 39 | use_backend be1 |
| 40 | } -start |
| 41 | |
| 42 | client c1 -connect ${h1_fe1_sock} { |
| 43 | send "GET" |
| 44 | send " " |
| 45 | send "/this-is-a-long-url" |
| 46 | send "-this-is-a-long-url" |
| 47 | send "-this-is-a-long-url" |
| 48 | send "-this-is-a-long-url" |
| 49 | send "-this-is-a-long-url" |
| 50 | send "-this-is-a-long-url" |
| 51 | send "-this-is-a-long-url" |
| 52 | send " HTT" |
| 53 | send "P/1.1" |
| 54 | send "\r" |
| 55 | send "\n" |
| 56 | send "Content-Length: 209\r\n\r\n" |
| 57 | send "abcdefghijklmnopqrstuvwxyz" |
| 58 | send "abcdefghijklmnopqrstuvwxyz" |
| 59 | send "abcdefghijklmnopqrstuvwxyz" |
| 60 | send "abcdefghijklmnopqrstuvwxyz" |
| 61 | send "abcdefghijklmnopqrstuvwxyz" |
| 62 | send "abcdefghijklmnopqrstuvwxyz" |
| 63 | send "abcdefghijklmnopqrstuvwxyz" |
| 64 | send "abcdefghijklmnopqrstuvwxyz" |
| 65 | rxresp |
| 66 | expect resp.status == 408 |
| 67 | } -run |
| 68 | |
| 69 | client c2 -connect ${h1_fe1_sock} { |
| 70 | txreq -bodylen 257 |
| 71 | rxresp |
| 72 | expect resp.status == 200 |
| 73 | } -run |
| 74 | |
| 75 | syslog S -wait |
| 76 | |