fix pipelining of requests with bodies
[rainbows.git] / t / t0106-rack-input-keepalive.sh
blobc4a531d2f6c55177d94e09d13e8c7277b691074c
1 #!/bin/sh
2 . ./test-lib.sh
3 t_plan 7 "rack.input pipelining test"
5 t_begin "setup and startup" && {
6 rainbows_setup $model
7 rtmpfiles req
8 rainbows -D sha1.ru -c $unicorn_config
9 body=hello
10 body_size=$(printf $body | wc -c)
11 body_sha1=$(printf $body | rsha1)
12 rainbows_wait_start
15 t_begin "send pipelined identity requests" && {
18 printf 'PUT / HTTP/1.0\r\n'
19 printf 'Connection: keep-alive\r\n'
20 printf 'Content-Length: %d\r\n\r\n%s' $body_size $body
21 printf 'PUT / HTTP/1.1\r\nHost: example.com\r\n'
22 printf 'Content-Length: %d\r\n\r\n%s' $body_size $body
23 printf 'PUT / HTTP/1.0\r\n'
24 printf 'Content-Length: %d\r\n\r\n%s' $body_size $body
25 } > $req
27 cat $fifo > $tmp &
28 cat $req
29 wait
30 echo ok > $ok
31 ) | socat - TCP4:$listen > $fifo
32 test x"$(cat $ok)" = xok
35 t_begin "check responses" && {
36 dbgcat tmp
37 test 3 -eq $(grep $body_sha1 $tmp | wc -l)
40 t_begin "send pipelined chunked requests" && {
43 printf 'PUT / HTTP/1.0\r\n'
44 printf 'Connection: keep-alive\r\n'
45 printf 'Transfer-Encoding: chunked\r\n\r\n'
46 printf '%x\r\n%s\r\n0\r\n\r\n' $body_size $body
47 printf 'PUT / HTTP/1.1\r\nHost: example.com\r\n'
48 printf 'Transfer-Encoding: chunked\r\n\r\n'
49 printf '%x\r\n%s\r\n0\r\n\r\n' $body_size $body
50 printf 'PUT / HTTP/1.0\r\n'
51 printf 'Transfer-Encoding: chunked\r\n\r\n'
52 printf '%x\r\n%s\r\n0\r\n\r\n' $body_size $body
53 } > $req
55 cat $fifo > $tmp &
56 cat $req
57 wait
58 echo ok > $ok
59 ) | socat - TCP4:$listen > $fifo
60 test x"$(cat $ok)" = xok
63 t_begin "check responses" && {
64 dbgcat tmp
65 test 3 -eq $(grep $body_sha1 $tmp | wc -l)
68 t_begin "kill server" && kill $rainbows_pid
70 t_begin "no errors in stderr log" && check_stderr
72 t_done