about summary refs log tree commit homepage
path: root/t
diff options
context:
space:
mode:
Diffstat (limited to 't')
-rwxr-xr-xt/t9001-sendfile-to-path.sh45
-rw-r--r--t/t9001.ru11
2 files changed, 56 insertions, 0 deletions
diff --git a/t/t9001-sendfile-to-path.sh b/t/t9001-sendfile-to-path.sh
new file mode 100755
index 0000000..aa75f22
--- /dev/null
+++ b/t/t9001-sendfile-to-path.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+. ./test-lib.sh
+
+t_plan 7 "Sendfile middleware test for $model"
+
+t_begin "configure and start" && {
+        rtmpfiles curl_out curl_err
+        rainbows_setup
+
+        # do not allow default middleware to be loaded since it may
+        # kill body#to_path
+        rainbows -E none -D t9001.ru -c $unicorn_config
+        rainbows_wait_start
+}
+
+t_begin "hit with curl" && {
+        curl -sSfv http://$listen/ > $curl_out 2> $curl_err
+}
+
+t_begin "kill server" && {
+        kill $rainbows_pid
+}
+
+t_begin "file matches source" && {
+        cmp $curl_out random_blob
+}
+
+t_begin "no errors in Rainbows! stderr" && {
+        check_stderr
+}
+
+t_begin "X-Sendfile does not show up in headers" && {
+        dbgcat curl_err
+        if grep -i x-sendfile $curl_err
+        then
+                die "X-Sendfile did show up!"
+        fi
+}
+
+t_begin "Content-Length is set correctly in headers" && {
+        expect=$(wc -c < random_blob)
+        grep "^< Content-Length: $expect" $curl_err
+}
+
+t_done
diff --git a/t/t9001.ru b/t/t9001.ru
new file mode 100644
index 0000000..0a523b9
--- /dev/null
+++ b/t/t9001.ru
@@ -0,0 +1,11 @@
+use Rainbows::Sendfile
+run lambda { |env|
+  path = "#{Dir.pwd}/random_blob"
+  [ 200,
+    {
+      'X-Sendfile' => path,
+      'Content-Type' => 'application/octet-stream'
+    },
+    []
+  ]
+}