| Class | WEBrick::HTTPServlet::AbstractServlet |
| In: |
lib/webrick/httpservlet/abstract.rb
|
| Parent: | Object |
# File lib/webrick/httpservlet/abstract.rb, line 22
22: def self.get_instance(config, *options)
23: self.new(config, *options)
24: end
# File lib/webrick/httpservlet/abstract.rb, line 26
26: def initialize(server, *options)
27: @server = @config = server
28: @logger = @server[:Logger]
29: @options = options
30: end
# File lib/webrick/httpservlet/abstract.rb, line 42
42: def do_GET(req, res)
43: raise HTTPStatus::NotFound, "not found."
44: end
# File lib/webrick/httpservlet/abstract.rb, line 46
46: def do_HEAD(req, res)
47: do_GET(req, res)
48: end
# File lib/webrick/httpservlet/abstract.rb, line 50
50: def do_OPTIONS(req, res)
51: m = self.methods.grep(/^do_[A-Z]+$/)
52: m.collect!{|i| i.sub(/do_/, "") }
53: m.sort!
54: res["allow"] = m.join(",")
55: end
# File lib/webrick/httpservlet/abstract.rb, line 32
32: def service(req, res)
33: method_name = "do_" + req.request_method.gsub(/-/, "_")
34: if respond_to?(method_name)
35: __send__(method_name, req, res)
36: else
37: raise HTTPStatus::MethodNotAllowed,
38: "unsupported method `#{req.request_method}'."
39: end
40: end
# File lib/webrick/httpservlet/abstract.rb, line 59
59: def redirect_to_directory_uri(req, res)
60: if req.path[-1] != ?/
61: location = WEBrick::HTTPUtils.escape_path(req.path + "/")
62: if req.query_string && req.query_string.size > 0
63: location << "?" << req.query_string
64: end
65: res.set_redirect(HTTPStatus::MovedPermanently, location)
66: end
67: end