diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-10-18 18:03:51 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-10-18 18:03:51 +0000 |
commit | 3555fdce0c9cf9bb6860a79fdc6843a1e96c9888 (patch) | |
tree | 294bea65cd10359ec3acfd8435db414da595da11 /test/test_server.rb | |
parent | 32998f5d56ada5968139cec91cea289e6ffa52bb (diff) | |
download | yahns-3555fdce0c9cf9bb6860a79fdc6843a1e96c9888.tar.gz |
Some users may wish to disable persistent connections for testing or whatever reason, let them. We'll also be using this feature to force SIGQUIT to expire clients.
Diffstat (limited to 'test/test_server.rb')
-rw-r--r-- | test/test_server.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/test_server.rb b/test/test_server.rb index 958b4f0..289770d 100644 --- a/test/test_server.rb +++ b/test/test_server.rb @@ -380,4 +380,32 @@ class TestServer < Testcase end [ pid, host, port ] end + + def test_nonpersistent + err = @err + cfg = Yahns::Config.new + host, port = @srv.addr[3], @srv.addr[1] + cfg.instance_eval do + ru = lambda { |_| [ 200, {'Content-Length'=>'2'}, ['HI'] ] } + GTL.synchronize { + app(:rack, ru) { + listen "#{host}:#{port}" + persistent_connections false + } + } + logger(Logger.new(err.path)) + end + srv = Yahns::Server.new(cfg) + pid = fork do + ENV["YAHNS_FD"] = @srv.fileno.to_s + srv.start.join + end + c = TCPSocket.new(host, port) + c.write("GET / HTTP/1.1\r\nHost: example.com\r\n\r\n") + buf = Timeout.timeout(10) { c.read } + assert_match(/Connection: close/, buf) + c.close + ensure + quit_wait(pid) + end end |