stream_response_epoll: our most "special" concurrency option yet
[rainbows.git] / t / t0021-sendfile-wrap-to_path.sh
blob77437b67a0bfd75c8122abd3967a020d48ed7788
1 #!/bin/sh
2 . ./test-lib.sh
3 skip_models StreamResponseEpoll
4 test -r random_blob || die "random_blob required, run with 'make $0'"
5 case $RUBY_ENGINE in
6 ruby) ;;
7 *)
8 t_info "skipping $T since it can't load the sendfile gem, yet"
9 exit 0
11 esac
13 t_plan 16 "sendfile wrap body response for $model"
15 t_begin "setup and startup" && {
16 rtmpfiles out err http_fifo sub_ok
17 rainbows_setup $model
18 echo 'require "sendfile"' >> $unicorn_config
19 echo 'def (::IO).copy_stream(*x); abort "NO"; end' >> $unicorn_config
21 # can't load Rack::Lint here since it clobbers body#to_path
22 export fifo
23 rainbows -E none -D file-wrap-to_path.ru -c $unicorn_config
24 rainbows_wait_start
27 t_begin "read random blob sha1" && {
28 random_blob_sha1=$(rsha1 < random_blob)
31 t_begin "start FIFO reader" && {
32 cat $fifo > $out &
35 t_begin "single request matches" && {
36 sha1=$(curl -sSfv 2> $err http://$listen/random_blob | rsha1)
37 test -n "$sha1"
38 test x"$sha1" = x"$random_blob_sha1"
41 t_begin "body.close called" && {
42 wait # for cat $fifo
43 grep CLOSING $out || die "body.close not logged"
46 t_begin "start FIFO reader for abortive HTTP/1.1 request" && {
47 cat $fifo > $out &
50 t_begin "send abortive HTTP/1.1 request" && {
51 rm -f $ok
53 printf 'GET /random_blob HTTP/1.1\r\nHost: example.com\r\n\r\n'
54 dd bs=4096 count=1 < $http_fifo >/dev/null
55 echo ok > $ok
56 ) | socat - TCP:$listen > $http_fifo || :
57 test xok = x$(cat $ok)
60 t_begin "body.close called for aborted HTTP/1.1 request" && {
61 wait # for cat $fifo
62 grep CLOSING $out || die "body.close not logged"
65 t_begin "start FIFO reader for abortive HTTP/1.0 request" && {
66 cat $fifo > $out &
69 t_begin "send abortive HTTP/1.0 request" && {
70 rm -f $ok
72 printf 'GET /random_blob HTTP/1.0\r\n\r\n'
73 dd bs=4096 count=1 < $http_fifo >/dev/null
74 echo ok > $ok
75 ) | socat - TCP:$listen > $http_fifo || :
76 test xok = x$(cat $ok)
79 t_begin "body.close called for aborted HTTP/1.0 request" && {
80 wait # for cat $fifo
81 grep CLOSING $out || die "body.close not logged"
84 t_begin "start FIFO reader for abortive HTTP/0.9 request" && {
85 cat $fifo > $out &
88 t_begin "send abortive HTTP/0.9 request" && {
89 rm -f $ok
91 printf 'GET /random_blob\r\n'
92 dd bs=4096 count=1 < $http_fifo >/dev/null
93 echo ok > $ok
94 ) | socat - TCP:$listen > $http_fifo || :
95 test xok = x$(cat $ok)
98 t_begin "body.close called for aborted HTTP/0.9 request" && {
99 wait # for cat $fifo
100 grep CLOSING $out || die "body.close not logged"
103 t_begin "shutdown server" && {
104 kill -QUIT $rainbows_pid
107 t_begin "check stderr" && check_stderr
109 t_done