tests: "wc -c" portability for *BSDs
[rainbows.git] / t / t0106-rack-input-keepalive.sh
blob4bc65a1ceb036814d04731c0ef4873256e04971c
1 #!/bin/sh
2 . ./test-lib.sh
3 skip_models StreamResponseEpoll
4 t_plan 11 "rack.input pipelining test"
6 t_begin "setup and startup" && {
7 rainbows_setup $model
8 rtmpfiles req
9 rainbows -D sha1.ru -c $unicorn_config
10 body=hello
11 body_size=$(printf $body | count_bytes)
12 body_sha1=$(printf $body | rsha1)
13 random_blob_size=$(count_bytes < random_blob)
14 random_blob_sha1=$(rsha1 < random_blob)
15 rainbows_wait_start
18 t_begin "send big pipelined chunked requests" && {
20 cat $fifo > $tmp &
21 Connection=keep-alive
22 export Connection
23 content-md5-put < random_blob
24 content-md5-put < random_blob
25 content-md5-put < random_blob
26 printf 'PUT / HTTP/1.0\r\n'
27 printf 'Content-Length: %d\r\n\r\n' $random_blob_size
28 cat random_blob
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 4 -eq $(grep $random_blob_sha1 $tmp | wc -l)
40 t_begin "send big pipelined identity requests" && {
42 cat $fifo > $tmp &
43 printf 'PUT / HTTP/1.0\r\n'
44 printf 'Connection: keep-alive\r\n'
45 printf 'Content-Length: %d\r\n\r\n' $random_blob_size
46 cat random_blob
47 printf 'PUT / HTTP/1.1\r\n'
48 printf 'Content-Length: %d\r\n\r\n' $random_blob_size
49 cat random_blob
50 printf 'PUT / HTTP/1.0\r\n'
51 printf 'Content-Length: %d\r\n\r\n' $random_blob_size
52 cat random_blob
53 wait
54 echo ok > $ok
55 ) | socat - TCP4:$listen > $fifo
56 test x"$(cat $ok)" = xok
59 t_begin "check responses" && {
60 dbgcat tmp
61 test 3 -eq $(grep $random_blob_sha1 $tmp | wc -l)
64 t_begin "send pipelined identity requests" && {
67 printf 'PUT / HTTP/1.0\r\n'
68 printf 'Connection: keep-alive\r\n'
69 printf 'Content-Length: %d\r\n\r\n%s' $body_size $body
70 printf 'PUT / HTTP/1.1\r\nHost: example.com\r\n'
71 printf 'Content-Length: %d\r\n\r\n%s' $body_size $body
72 printf 'PUT / HTTP/1.0\r\n'
73 printf 'Content-Length: %d\r\n\r\n%s' $body_size $body
74 } > $req
76 cat $fifo > $tmp &
77 cat $req
78 wait
79 echo ok > $ok
80 ) | socat - TCP4:$listen > $fifo
81 test x"$(cat $ok)" = xok
84 t_begin "check responses" && {
85 dbgcat tmp
86 test 3 -eq $(grep $body_sha1 $tmp | wc -l)
89 t_begin "send pipelined chunked requests" && {
92 printf 'PUT / HTTP/1.0\r\n'
93 printf 'Connection: keep-alive\r\n'
94 printf 'Transfer-Encoding: chunked\r\n\r\n'
95 printf '%x\r\n%s\r\n0\r\n\r\n' $body_size $body
96 printf 'PUT / HTTP/1.1\r\nHost: example.com\r\n'
97 printf 'Transfer-Encoding: chunked\r\n\r\n'
98 printf '%x\r\n%s\r\n0\r\n\r\n' $body_size $body
99 printf 'PUT / HTTP/1.0\r\n'
100 printf 'Transfer-Encoding: chunked\r\n\r\n'
101 printf '%x\r\n%s\r\n0\r\n\r\n' $body_size $body
102 } > $req
104 cat $fifo > $tmp &
105 cat $req
106 wait
107 echo ok > $ok
108 ) | socat - TCP4:$listen > $fifo
109 test x"$(cat $ok)" = xok
112 t_begin "check responses" && {
113 dbgcat tmp
114 test 3 -eq $(grep $body_sha1 $tmp | wc -l)
117 t_begin "kill server" && kill $rainbows_pid
119 t_begin "no errors in stderr log" && check_stderr
121 t_done