document RubyGem requirements
[rainbows.git] / t / t0032-close-pipe-to_path-response.sh
blobe3d8f1bd3ea1d7be32c9d69ffdda318ee3710cb5
1 #!/bin/sh
2 . ./test-lib.sh
3 if ! test -d /dev/fd
4 then
5 t_info "skipping $T since /dev/fd is required"
6 exit 0
7 fi
9 t_plan 16 "close pipe to_path response for $model"
11 t_begin "setup and startup" && {
12 rtmpfiles err out http_fifo sub_ok
13 rainbows_setup $model
14 export fifo
15 rainbows -E none -D close-pipe-to_path-response.ru -c $unicorn_config
16 rainbows_wait_start
19 t_begin "read random blob sha1" && {
20 random_blob_sha1=$(rsha1 < random_blob)
23 t_begin "start FIFO reader" && {
24 cat $fifo > $out &
27 t_begin "single request matches" && {
28 sha1=$(curl -sSfv 2> $err http://$listen/ | rsha1)
29 test -n "$sha1"
30 test x"$sha1" = x"$random_blob_sha1"
33 t_begin "body.close called" && {
34 wait # for cat $fifo
35 grep CLOSING $out || die "body.close not logged"
38 t_begin "start FIFO reader for abortive HTTP/1.1 request" && {
39 cat $fifo > $out &
42 t_begin "send abortive HTTP/1.1 request" && {
43 rm -f $ok
45 printf 'GET /random_blob HTTP/1.1\r\nHost: example.com\r\n\r\n'
46 dd bs=4096 count=1 < $http_fifo >/dev/null
47 echo ok > $ok
48 ) | socat - TCP:$listen > $http_fifo || :
49 test xok = x$(cat $ok)
52 t_begin "body.close called for aborted HTTP/1.1 request" && {
53 wait # for cat $fifo
54 grep CLOSING $out || die "body.close not logged"
57 t_begin "start FIFO reader for abortive HTTP/1.0 request" && {
58 cat $fifo > $out &
61 t_begin "send abortive HTTP/1.0 request" && {
62 rm -f $ok
64 printf 'GET /random_blob HTTP/1.0\r\n\r\n'
65 dd bs=4096 count=1 < $http_fifo >/dev/null
66 echo ok > $ok
67 ) | socat - TCP:$listen > $http_fifo || :
68 test xok = x$(cat $ok)
71 t_begin "body.close called for aborted HTTP/1.0 request" && {
72 wait # for cat $fifo
73 grep CLOSING $out || die "body.close not logged"
76 t_begin "start FIFO reader for abortive HTTP/0.9 request" && {
77 cat $fifo > $out &
80 t_begin "send abortive HTTP/0.9 request" && {
81 rm -f $ok
83 printf 'GET /random_blob\r\n'
84 dd bs=4096 count=1 < $http_fifo >/dev/null
85 echo ok > $ok
86 ) | socat - TCP:$listen > $http_fifo || :
87 test xok = x$(cat $ok)
90 t_begin "body.close called for aborted HTTP/0.9 request" && {
91 wait # for cat $fifo
92 grep CLOSING $out || die "body.close not logged"
95 t_begin "shutdown server" && {
96 kill -QUIT $rainbows_pid
99 t_begin "check stderr" && check_stderr
101 t_done