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