diff --git a/lib/webrick/httpservlet/abstract.rb b/lib/webrick/httpservlet/abstract.rb index 2a0a404..cad2634 100644 --- a/lib/webrick/httpservlet/abstract.rb +++ b/lib/webrick/httpservlet/abstract.rb @@ -48,10 +48,9 @@ module WEBrick end def do_OPTIONS(req, res) - m = self.methods.grep(/^do_[A-Z]+$/) - m.collect!{|i| i.sub(/do_/, "") } - m.sort! - res["allow"] = m.join(",") + res["allow"] = methods.grep(/^do_[A-Z]+$/).collect { |m| + m.to_s.sub(/do_/, "") + }.sort.join(',') end private diff --git a/test/webrick/test_filehandler.rb b/test/webrick/test_filehandler.rb index 712ff7b..2a1c0df 100644 --- a/test/webrick/test_filehandler.rb +++ b/test/webrick/test_filehandler.rb @@ -40,6 +40,23 @@ class WEBrick::TestFileHandler < Test::Unit::TestCase return res end + def test_do_options + req = WEBrick::HTTPRequest.new(WEBrick::Config::HTTP) + res = WEBrick::HTTPResponse.new(WEBrick::Config::HTTP) + handler = default_file_handler(__FILE__) + handler.do_OPTIONS(req, res) + allow_list = res['allow'].split(',') + + assert allow_list.length > 0, "allow list should be greater than 0" + + res['allow'].split(',').each do |option| + assert( + handler.respond_to?(:"do_#{option}"), + "handler should respond to do_#{option}" + ) + end + end + def test_make_partial_content filename = __FILE__ filesize = File.size(filename)