From f69cec0b80b445f848f110ed01fb183c1498b623 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 1 Nov 2013 22:01:45 +0000 Subject: test trysendfile usage with UNIX sockets We didn't cover this before. --- test/test_serve_static.rb | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'test/test_serve_static.rb') 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 -- cgit v1.2.3-24-ge0c7