diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/webrick/test_cgi.rb | 2 | ||||
-rw-r--r-- | test/webrick/test_httpproxy.rb | 10 | ||||
-rw-r--r-- | test/webrick/test_httpserver.rb | 18 |
3 files changed, 24 insertions, 6 deletions
diff --git a/test/webrick/test_cgi.rb b/test/webrick/test_cgi.rb index 4bfb3df388..11853161b1 100644 --- a/test/webrick/test_cgi.rb +++ b/test/webrick/test_cgi.rb @@ -10,7 +10,7 @@ class TestWEBrickCGI < Test::Unit::TestCase :CGIInterpreter => TestWEBrick::RubyBin, :DocumentRoot => File.dirname(__FILE__), :DirectoryIndex => ["webrick.cgi"], - :RequestHandler => Proc.new{|req, res| + :RequestCallback => Proc.new{|req, res| def req.meta_vars meta = super meta["RUBYLIB"] = $:.join(File::PATH_SEPARATOR) diff --git a/test/webrick/test_httpproxy.rb b/test/webrick/test_httpproxy.rb index 58b834fe36..cab7095d12 100644 --- a/test/webrick/test_httpproxy.rb +++ b/test/webrick/test_httpproxy.rb @@ -33,7 +33,7 @@ class TestWEBrickHTTPProxy < Test::Unit::TestCase config = { :ServerName => "localhost.localdomain", :ProxyContentHandler => Proc.new{|req, res| proxy_handler_called += 1 }, - :RequestHandler => Proc.new{|req, res| request_handler_called += 1 } + :RequestCallback => Proc.new{|req, res| request_handler_called += 1 } } TestWEBrick.start_httpproxy(config){|server, addr, port, log| server.mount_proc("/"){|req, res| @@ -78,7 +78,7 @@ class TestWEBrickHTTPProxy < Test::Unit::TestCase config = { :ServerName => "localhost.localdomain", :ProxyContentHandler => Proc.new{|req, res| proxy_handler_called += 1 }, - :RequestHandler => Proc.new{|req, res| request_handler_called += 1 } + :RequestCallback => Proc.new{|req, res| request_handler_called += 1 } } TestWEBrick.start_httpproxy(config){|server, addr, port, log| server.mount_proc("/"){|req, res| @@ -143,7 +143,7 @@ class TestWEBrickHTTPProxy < Test::Unit::TestCase } config = { :ServerName => "localhost.localdomain", - :RequestHandler => Proc.new{|req, res| + :RequestCallback => Proc.new{|req, res| assert_equal("CONNECT", req.request_method) }, } @@ -185,7 +185,7 @@ class TestWEBrickHTTPProxy < Test::Unit::TestCase up_config = { :ServerName => "localhost.localdomain", :ProxyContentHandler => Proc.new{|req, res| up_proxy_handler_called += 1}, - :RequestHandler => Proc.new{|req, res| up_request_handler_called += 1} + :RequestCallback => Proc.new{|req, res| up_request_handler_called += 1} } TestWEBrick.start_httpproxy(up_config){|up_server, up_addr, up_port, up_log| up_server.mount_proc("/"){|req, res| @@ -195,7 +195,7 @@ class TestWEBrickHTTPProxy < Test::Unit::TestCase :ServerName => "localhost.localdomain", :ProxyURI => URI.parse("http://localhost:#{up_port}"), :ProxyContentHandler => Proc.new{|req, res| proxy_handler_called += 1}, - :RequestHandler => Proc.new{|req, res| request_handler_called += 1}, + :RequestCallback => Proc.new{|req, res| request_handler_called += 1}, } TestWEBrick.start_httpproxy(config){|server, addr, port, log| http = Net::HTTP.new(up_addr, up_port, addr, port) diff --git a/test/webrick/test_httpserver.rb b/test/webrick/test_httpserver.rb index e0c2ae33ad..b4bdd84045 100644 --- a/test/webrick/test_httpserver.rb +++ b/test/webrick/test_httpserver.rb @@ -257,4 +257,22 @@ class TestWEBrickHTTPServer < Test::Unit::TestCase assert_equal(started, 1) assert_equal(stopped, 1) end + + def test_request_handler_callback_is_deprecated + requested = 0 + config = { + :ServerName => "localhost", + :RequestHandler => Proc.new{|req, res| requested += 1 }, + } + TestWEBrick.start_httpserver(config){|server, addr, port, log| + true while server.status != :Running + + http = Net::HTTP.new(addr, port) + req = Net::HTTP::Get.new("/") + req["Host"] = "localhost:#{port}" + http.request(req){|res| assert_equal("404", res.code, log.call)} + assert_match(%r{:RequestHandler is deprecated, please use :RequestCallback$}, log.call, log.call) + } + assert_equal(requested, 1) + end end |