Rainbows! 5.2.1
[rainbows.git] / t / t0032-close-pipe-to_path-response.sh
blob8092930e9db2107929e3664270ecb25e35ae29c9
1 #!/bin/sh
2 . ./test-lib.sh
3 skip_models StreamResponseEpoll
4 if ! test -d /dev/fd
5 then
6 t_info "skipping $T since /dev/fd is required"
7 exit 0
8 fi
10 t_plan 16 "close pipe to_path response for $model"
12 t_begin "setup and startup" && {
13 rtmpfiles err out http_fifo sub_ok
14 rainbows_setup $model
15 export fifo
16 rainbows -E none -D close-pipe-to_path-response.ru -c $unicorn_config
17 rainbows_wait_start
20 t_begin "read random blob sha1" && {
21 random_blob_sha1=$(rsha1 < random_blob)
24 t_begin "start FIFO reader" && {
25 cat $fifo > $out &
28 t_begin "single request matches" && {
29 sha1=$(curl -sSfv 2> $err http://$listen/ | rsha1)
30 test -n "$sha1"
31 test x"$sha1" = x"$random_blob_sha1"
34 t_begin "body.close called" && {
35 wait # for cat $fifo
36 grep CLOSING $out || die "body.close not logged"
39 t_begin "start FIFO reader for abortive HTTP/1.1 request" && {
40 cat $fifo > $out &
43 t_begin "send abortive HTTP/1.1 request" && {
44 rm -f $ok
46 printf 'GET /random_blob HTTP/1.1\r\nHost: example.com\r\n\r\n'
47 dd bs=4096 count=1 < $http_fifo >/dev/null
48 echo ok > $ok
49 ) | socat - TCP:$listen > $http_fifo || :
50 test xok = x$(cat $ok)
53 t_begin "body.close called for aborted HTTP/1.1 request" && {
54 wait # for cat $fifo
55 grep CLOSING $out || die "body.close not logged"
58 t_begin "start FIFO reader for abortive HTTP/1.0 request" && {
59 cat $fifo > $out &
62 t_begin "send abortive HTTP/1.0 request" && {
63 rm -f $ok
65 printf 'GET /random_blob HTTP/1.0\r\n\r\n'
66 dd bs=4096 count=1 < $http_fifo >/dev/null
67 echo ok > $ok
68 ) | socat - TCP:$listen > $http_fifo || :
69 test xok = x$(cat $ok)
72 t_begin "body.close called for aborted HTTP/1.0 request" && {
73 wait # for cat $fifo
74 grep CLOSING $out || die "body.close not logged"
77 t_begin "start FIFO reader for abortive HTTP/0.9 request" && {
78 cat $fifo > $out &
81 t_begin "send abortive HTTP/0.9 request" && {
82 rm -f $ok
84 printf 'GET /random_blob\r\n'
85 dd bs=4096 count=1 < $http_fifo >/dev/null
86 echo ok > $ok
87 ) | socat - TCP:$listen > $http_fifo || :
88 test xok = x$(cat $ok)
91 t_begin "body.close called for aborted HTTP/0.9 request" && {
92 wait # for cat $fifo
93 grep CLOSING $out || die "body.close not logged"
96 t_begin "shutdown server" && {
97 kill -QUIT $rainbows_pid
100 t_begin "check stderr" && check_stderr
102 t_done