about summary refs log tree commit homepage
path: root/test/test_serve_static.rb
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2013-11-01 22:01:45 +0000
committerEric Wong <normalperson@yhbt.net>2013-11-01 22:01:45 +0000
commitf69cec0b80b445f848f110ed01fb183c1498b623 (patch)
tree7e9ef11b3574aa92e18214c17e6f67a45fe8aac2 /test/test_serve_static.rb
parentbfe213a1c3918befd4a26b1d64a61a21486d81ba (diff)
downloadyahns-f69cec0b80b445f848f110ed01fb183c1498b623.tar.gz
We didn't cover this before.
Diffstat (limited to 'test/test_serve_static.rb')
-rw-r--r--test/test_serve_static.rb15
1 files changed, 14 insertions, 1 deletions
diff --git a/test/test_serve_static.rb b/test/test_serve_static.rb
index 6cb337e..b1817f7 100644
--- a/test/test_serve_static.rb
+++ b/test/test_serve_static.rb
@@ -10,12 +10,17 @@ class TestServeStatic < Testcase
   alias teardown server_helper_teardown
 
   def test_serve_static
+    tmpdir = Dir.mktmpdir
+    sock = "#{tmpdir}/sock"
     err = @err
     cfg = Yahns::Config.new
     host, port = @srv.addr[3], @srv.addr[1]
     cfg.instance_eval do
       GTL.synchronize do
-        app(:rack, Rack::File.new(Dir.pwd)) { listen "#{host}:#{port}" }
+        app(:rack, Rack::File.new(Dir.pwd)) {
+          listen sock
+          listen "#{host}:#{port}"
+        }
       end
       logger(Logger.new(err.path))
     end
@@ -29,8 +34,16 @@ class TestServeStatic < Testcase
       res = http.request(req)
       assert_equal gplv3[5..46], res.body
     end
+
+    # ensure sendfile works on Unix sockets
+    s = UNIXSocket.new(sock)
+    s.close_on_exec = true
+    s.write "GET /COPYING\r\n\r\n"
+    assert_equal gplv3, Timeout.timeout(30) { s.read }
+    s.close
   ensure
     quit_wait(pid)
+    FileUtils.rm_rf tmpdir
   end
 
   def test_serve_static_blocked_header