event_machine: factor out async.callback handling
[rainbows.git] / t / t0030-fast-pipe-response.sh
blobf81029a4e9569ffde95364899d8ee827cf428219
1 #!/bin/sh
2 . ./test-lib.sh
3 test -r random_blob || die "random_blob required, run with 'make $0'"
5 t_plan 10 "fast pipe response for $model"
7 t_begin "setup and startup" && {
8 rtmpfiles err out
9 rainbows_setup $model
10 rainbows -E none -D fast-pipe-response.ru -c $unicorn_config
11 rainbows_wait_start
14 t_begin "read random blob sha1" && {
15 random_blob_sha1=$(rsha1 < random_blob)
16 three_sha1=$(cat random_blob random_blob random_blob | rsha1)
19 t_begin "single request matches" && {
20 sha1=$(curl -sSfv 2> $err http://$listen/ | rsha1)
21 test -n "$sha1"
22 test x"$sha1" = x"$random_blob_sha1"
25 t_begin "Content-Length header preserved in response" && {
26 grep "^< Content-Length:" $err
29 t_begin "send three keep-alive requests" && {
30 sha1=$(curl -vsSf 2> $err \
31 http://$listen/ http://$listen/ http://$listen/ | rsha1)
32 test -n "$sha1"
33 test x"$sha1" = x"$three_sha1"
36 t_begin "ensure responses were all keep-alive" && {
37 test 3 -eq $(grep '< Connection: keep-alive' < $err | wc -l)
40 t_begin "HTTP/1.0 test" && {
41 sha1=$(curl -0 -v 2> $err -sSf http://$listen/ | rsha1)
42 test $sha1 = $random_blob_sha1
43 grep '< Connection: close' < $err
46 t_begin "HTTP/0.9 test" && {
48 printf 'GET /\r\n'
49 rsha1 < $fifo > $tmp &
50 wait
51 echo ok > $ok
52 ) | socat - TCP:$listen > $fifo
53 test $(cat $tmp) = $random_blob_sha1
54 test xok = x$(cat $ok)
57 t_begin "shutdown server" && {
58 kill -QUIT $rainbows_pid
61 t_begin "check stderr" && check_stderr
63 t_done