diff options
-rw-r--r-- | test/test_serve_static.rb | 15 |
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 |