3 skip_models StreamResponseEpoll
4 test -r random_blob || die
"random_blob required, run with 'make $0'"
8 t_info
"skipping $T since it can't load the sendfile gem, yet"
13 t_plan
16 "sendfile wrap body response for $model"
15 t_begin
"setup and startup" && {
16 rtmpfiles out err http_fifo sub_ok
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
23 rainbows
-E none
-D file-wrap-to_path.ru
-c $unicorn_config
27 t_begin
"read random blob sha1" && {
28 random_blob_sha1
=$
(rsha1
< random_blob
)
31 t_begin
"start FIFO reader" && {
35 t_begin
"single request matches" && {
36 sha1
=$
(curl
-sSfv 2> $err http
://$listen/random_blob | rsha1
)
38 test x
"$sha1" = x
"$random_blob_sha1"
41 t_begin
"body.close called" && {
43 grep CLOSING
$out || die
"body.close not logged"
46 t_begin
"start FIFO reader for abortive HTTP/1.1 request" && {
50 t_begin
"send abortive HTTP/1.1 request" && {
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
56 ) | socat
- TCP
:$listen > $http_fifo ||
:
57 test xok
= x$
(cat $ok)
60 t_begin
"body.close called for aborted HTTP/1.1 request" && {
62 grep CLOSING
$out || die
"body.close not logged"
65 t_begin
"start FIFO reader for abortive HTTP/1.0 request" && {
69 t_begin
"send abortive HTTP/1.0 request" && {
72 printf 'GET /random_blob HTTP/1.0\r\n\r\n'
73 dd bs
=4096 count
=1 < $http_fifo >/dev
/null
75 ) | socat
- TCP
:$listen > $http_fifo ||
:
76 test xok
= x$
(cat $ok)
79 t_begin
"body.close called for aborted HTTP/1.0 request" && {
81 grep CLOSING
$out || die
"body.close not logged"
84 t_begin
"start FIFO reader for abortive HTTP/0.9 request" && {
88 t_begin
"send abortive HTTP/0.9 request" && {
91 printf 'GET /random_blob\r\n'
92 dd bs
=4096 count
=1 < $http_fifo >/dev
/null
94 ) | socat
- TCP
:$listen > $http_fifo ||
:
95 test xok
= x$
(cat $ok)
98 t_begin
"body.close called for aborted HTTP/0.9 request" && {
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