enable Range: responses for static files for most models
[rainbows.git] / t / t0023-sendfile-byte-range.sh
blob63fceee62da129370d6128f858bbaaa32a297645
1 #!/bin/sh
2 . ./test-lib.sh
3 test -r random_blob || die "random_blob required, run with 'make $0'"
4 case $RUBY_ENGINE in
5 ruby) ;;
6 *)
7 t_info "skipping $T since it can't load the sendfile gem, yet"
8 exit 0
9 ;;
10 esac
12 case $model in
13 EventMachine|NeverBlock|Revactor)
14 t_info "skipping $T since it's not compatible with $model"
15 exit 0
17 *) ;;
18 esac
20 t_plan 7 "sendfile byte range response for $model"
22 t_begin "setup and startup" && {
23 rtmpfiles out err
24 rainbows_setup $model
25 echo 'require "sendfile"' >> $unicorn_config
26 echo 'def (::IO).copy_stream(*x); abort "NO"; end' >> $unicorn_config
28 # can't load Rack::Lint here since it clobbers body#to_path
29 rainbows -E none -D large-file-response.ru -c $unicorn_config
30 rainbows_wait_start
31 range_head=-r-365
32 range_tail=-r155-
33 range_mid=-r200-300
36 t_begin "read random blob sha1s" && {
37 sha1_head=$(curl -sSf $range_head file://random_blob | rsha1)
38 sha1_tail=$(curl -sSf $range_tail file://random_blob | rsha1)
39 sha1_mid=$(curl -sSf $range_mid file://random_blob | rsha1)
42 t_begin "head range matches" && {
43 sha1="$(curl -sSv $range_head http://$listen/random_blob | rsha1)"
44 test x"$sha1_head" = x"$sha1"
47 t_begin "tail range matches" && {
48 sha1="$(curl -sS $range_tail http://$listen/random_blob | rsha1)"
49 test x"$sha1_tail" = x"$sha1"
52 t_begin "mid range matches" && {
53 sha1="$(curl -sS $range_mid http://$listen/random_blob | rsha1)"
54 test x"$sha1_mid" = x"$sha1"
57 t_begin "shutdown server" && {
58 kill -QUIT $rainbows_pid
61 t_begin "check stderr" && check_stderr
63 t_done