summaryrefslogtreecommitdiff
path: root/test/webrick
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-08 01:17:07 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-05-08 01:17:07 +0000
commit719804b5df99feb8f8b871051d64bdd73524511f (patch)
treed3629fdb8fcf5ba8040fdfcf125d5b5ad42da496 /test/webrick
parentb9f770ae8ffe2c5f83b5f411534c6d5c2f687345 (diff)
webrick/httpserver.rb: Stop handling requests on shutdown
* lib/webrick/httpserver.rb (WEBrick::HTTPServer#run): stop handling requests on shutdown, even if the socket is readable and IO.select() returns true. [Fixes GH-607] * lib/webrick/server.rb (WEBrick::GenericServer#start): IO.select() raises ENOTSOCK on shutdown on Windows. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45872 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/webrick')
-rw-r--r--test/webrick/test_httpserver.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/webrick/test_httpserver.rb b/test/webrick/test_httpserver.rb
index ffebf7e..3e19a56 100644
--- a/test/webrick/test_httpserver.rb
+++ b/test/webrick/test_httpserver.rb
@@ -366,4 +366,27 @@ class TestWEBrickHTTPServer < Test::Unit::TestCase
}
assert_equal(requested, 1)
end
+
+ def test_shutdown_with_busy_keepalive_connection
+ requested = 0
+ config = {
+ :ServerName => "localhost",
+ }
+ TestWEBrick.start_httpserver(config){|server, addr, port, log|
+ server.mount_proc("/", lambda {|req, res| res.body = "heffalump" })
+ Thread.pass while server.status != :Running
+
+ Net::HTTP.start(addr, port) do |http|
+ req = Net::HTTP::Get.new("/")
+ http.request(req){|res| assert_equal('Keep-Alive', res['Connection'], log.call) }
+ server.shutdown
+ begin
+ 10.times {|n| http.request(req); requested += 1 }
+ rescue
+ # Errno::ECONNREFUSED or similar
+ end
+ end
+ }
+ assert_equal(0, requested, "Server responded to #{requested} requests after shutdown")
+ end
end