diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-07-19 10:10:08 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-07-19 17:04:39 -0700 |
commit | 9c8372c3a4972cacf0eb15ad85d34cb33293672e (patch) | |
tree | 1998fa98415c7331c56c06de69d06069fd55154b /t/t0031-close-pipe-response.sh | |
parent | fa4eb71b8208f7fc4148a7f8dd916c2e0cd1cc8a (diff) | |
download | rainbows-9c8372c3a4972cacf0eb15ad85d34cb33293672e.tar.gz |
We need to remember to close response bodies even if a client aborts the connection, since body.close can trigger interesting things like logging and such...
Diffstat (limited to 't/t0031-close-pipe-response.sh')
-rwxr-xr-x[-rw-r--r--] | t/t0031-close-pipe-response.sh | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/t/t0031-close-pipe-response.sh b/t/t0031-close-pipe-response.sh index 7439b5f..58b6346 100644..100755 --- a/t/t0031-close-pipe-response.sh +++ b/t/t0031-close-pipe-response.sh @@ -1,19 +1,28 @@ #!/bin/sh . ./test-lib.sh -t_plan 5 "close pipe response for $model" +t_plan 10 "close pipe response for $model" t_begin "setup and startup" && { - rtmpfiles err out + rtmpfiles err out http_fifo sub_ok rainbows_setup $model export fifo rainbows -E none -D close-pipe-response.ru -c $unicorn_config rainbows_wait_start } -t_begin "single request matches" && { +t_begin "read random blob sha1" && { + random_blob_sha1=$(rsha1 < random_blob) +} + +t_begin "start FIFO reader" && { cat $fifo > $out & - test x'hello world' = x"$(curl -sSfv 2> $err http://$listen/)" +} + +t_begin "single request matches" && { + sha1=$(curl -sSfv 2> $err http://$listen/ | rsha1) + test -n "$sha1" + test x"$sha1" = x"$random_blob_sha1" } t_begin "body.close called" && { @@ -21,6 +30,24 @@ t_begin "body.close called" && { grep CLOSING $out || die "body.close not logged" } +t_begin "start FIFO reader for abortive request" && { + cat $fifo > $out & +} + +t_begin "send abortive request" && { + ( + printf 'GET /random_blob\r\n' + dd bs=4096 count=1 < $http_fifo >/dev/null + echo ok > $ok + ) | socat - TCP:$listen > $http_fifo || : + test xok = x$(cat $ok) +} + +t_begin "body.close called for aborted request" && { + wait # for cat $fifo + grep CLOSING $out || die "body.close not logged" +} + t_begin "shutdown server" && { kill -QUIT $rainbows_pid } |