ensure client aborted file/stream response bodies are closed
[rainbows.git] / t / t0031-close-pipe-response.sh
blob58b6346b6aad00fed59f3b0ba2d1d08195d11658
1 #!/bin/sh
2 . ./test-lib.sh
4 t_plan 10 "close pipe response for $model"
6 t_begin "setup and startup" && {
7 rtmpfiles err out http_fifo sub_ok
8 rainbows_setup $model
9 export fifo
10 rainbows -E none -D close-pipe-response.ru -c $unicorn_config
11 rainbows_wait_start
14 t_begin "read random blob sha1" && {
15 random_blob_sha1=$(rsha1 < random_blob)
18 t_begin "start FIFO reader" && {
19 cat $fifo > $out &
22 t_begin "single request matches" && {
23 sha1=$(curl -sSfv 2> $err http://$listen/ | rsha1)
24 test -n "$sha1"
25 test x"$sha1" = x"$random_blob_sha1"
28 t_begin "body.close called" && {
29 wait # for cat $fifo
30 grep CLOSING $out || die "body.close not logged"
33 t_begin "start FIFO reader for abortive request" && {
34 cat $fifo > $out &
37 t_begin "send abortive request" && {
39 printf 'GET /random_blob\r\n'
40 dd bs=4096 count=1 < $http_fifo >/dev/null
41 echo ok > $ok
42 ) | socat - TCP:$listen > $http_fifo || :
43 test xok = x$(cat $ok)
46 t_begin "body.close called for aborted request" && {
47 wait # for cat $fifo
48 grep CLOSING $out || die "body.close not logged"
51 t_begin "shutdown server" && {
52 kill -QUIT $rainbows_pid
55 t_begin "check stderr" && check_stderr
57 t_done