3 test -r random_blob || die
"random_blob required, run with 'make $0'"
7 t_info
"skipping $T since it can't load the sendfile gem, yet"
12 t_plan
16 "sendfile wrap body response for $model"
14 t_begin
"setup and startup" && {
15 rtmpfiles out err http_fifo sub_ok
17 echo 'require "sendfile"' >> $unicorn_config
18 echo 'def (::IO).copy_stream(*x); abort "NO"; end' >> $unicorn_config
20 # can't load Rack::Lint here since it clobbers body#to_path
22 rainbows
-E none
-D file-wrap-to_path.ru
-c $unicorn_config
26 t_begin
"read random blob sha1" && {
27 random_blob_sha1
=$
(rsha1
< random_blob
)
30 t_begin
"start FIFO reader" && {
34 t_begin
"single request matches" && {
35 sha1
=$
(curl
-sSfv 2> $err http
://$listen/random_blob | rsha1
)
37 test x
"$sha1" = x
"$random_blob_sha1"
40 t_begin
"body.close called" && {
42 grep CLOSING
$out || die
"body.close not logged"
45 t_begin
"start FIFO reader for abortive HTTP/1.1 request" && {
49 t_begin
"send abortive HTTP/1.1 request" && {
52 printf 'GET /random_blob HTTP/1.1\r\nHost: example.com\r\n\r\n'
53 dd bs
=4096 count
=1 < $http_fifo >/dev
/null
55 ) | socat
- TCP
:$listen > $http_fifo ||
:
56 test xok
= x$
(cat $ok)
59 t_begin
"body.close called for aborted HTTP/1.1 request" && {
61 grep CLOSING
$out || die
"body.close not logged"
64 t_begin
"start FIFO reader for abortive HTTP/1.0 request" && {
68 t_begin
"send abortive HTTP/1.0 request" && {
71 printf 'GET /random_blob HTTP/1.0\r\n\r\n'
72 dd bs
=4096 count
=1 < $http_fifo >/dev
/null
74 ) | socat
- TCP
:$listen > $http_fifo ||
:
75 test xok
= x$
(cat $ok)
78 t_begin
"body.close called for aborted HTTP/1.0 request" && {
80 grep CLOSING
$out || die
"body.close not logged"
83 t_begin
"start FIFO reader for abortive HTTP/0.9 request" && {
87 t_begin
"send abortive HTTP/0.9 request" && {
90 printf 'GET /random_blob\r\n'
91 dd bs
=4096 count
=1 < $http_fifo >/dev
/null
93 ) | socat
- TCP
:$listen > $http_fifo ||
:
94 test xok
= x$
(cat $ok)
97 t_begin
"body.close called for aborted HTTP/0.9 request" && {
99 grep CLOSING
$out || die
"body.close not logged"
102 t_begin
"shutdown server" && {
103 kill -QUIT $rainbows_pid
106 t_begin
"check stderr" && check_stderr