diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-10-08 23:44:23 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-10-09 00:03:02 +0000 |
commit | 6eb46e422f4b2ba98c795fca5e18e7262c0c688e (patch) | |
tree | 805e041099199ce7e4154283b3e7b81d9485159d /t/t9000-preread-input.sh | |
parent | 9be78606355d4a0ad4ea59316ab2ce998c5b9a12 (diff) | |
download | unicorn-6eb46e422f4b2ba98c795fca5e18e7262c0c688e.tar.gz |
This may be useful for some apps that wish to drain the body before acquiring an app-wide lock. Maybe it's more useful with Rainbows!...
Diffstat (limited to 't/t9000-preread-input.sh')
-rwxr-xr-x | t/t9000-preread-input.sh | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/t/t9000-preread-input.sh b/t/t9000-preread-input.sh new file mode 100755 index 0000000..b9da05e --- /dev/null +++ b/t/t9000-preread-input.sh @@ -0,0 +1,48 @@ +#!/bin/sh +. ./test-lib.sh +t_plan 9 "PrereadInput middleware tests" + +t_begin "setup and start" && { + random_blob_sha1=$(rsha1 < random_blob) + unicorn_setup + unicorn -D -c $unicorn_config preread_input.ru + unicorn_wait_start +} + +t_begin "single identity request" && { + curl -sSf -T random_blob http://$listen/ > $tmp +} + +t_begin "sha1 matches" && { + test x"$(cat $tmp)" = x"$random_blob_sha1" +} + +t_begin "single chunked request" && { + curl -sSf -T- < random_blob http://$listen/ > $tmp +} + +t_begin "sha1 matches" && { + test x"$(cat $tmp)" = x"$random_blob_sha1" +} + +t_begin "app only dispatched twice" && { + test 2 -eq "$(grep 'app dispatch:' < $r_err | wc -l )" +} + +t_begin "aborted chunked request" && { + rm -f $tmp + curl -sSf -T- < $fifo http://$listen/ > $tmp & + curl_pid=$! + kill -9 $curl_pid + wait +} + +t_begin "app only dispatched twice" && { + test 2 -eq "$(grep 'app dispatch:' < $r_err | wc -l )" +} + +t_begin "killing succeeds" && { + kill -QUIT $unicorn_pid +} + +t_done |