diff -upr ./httprequest.rb ../webrick-dsc/httprequest.rb
--- ./httprequest.rb Mon Mar 18 16:48:03 2002
+++ ../webrick-dsc/httprequest.rb Sun Mar 17 11:50:05 2002
@@ -27,7 +27,7 @@ module WEBrick
attr_reader :query
attr_reader :config
attr_reader :peeraddr
- attr_accessor :script_name, :path_info
+ attr_accessor :script_name, :path_info, :path
def initialize(config)
@config = config
@@ -50,8 +50,18 @@ module WEBrick
@path_info = nil
@keep_alive = false
+ @attributes = {}
end
+ def set_attribute(name,value)
+ @attributes[name] = value
+ end
+ def get_attribute(name)
+ return @attributes[name]
+ end
+ def remove_attribute(name)
+ @attributes.delete(name)
+ end
def parse(socket)
read_request_line(socket)
read_header(socket)
diff -upr ./httpserver.rb ../webrick-dsc/httpserver.rb
--- ./httpserver.rb Mon Mar 18 16:48:03 2002
+++ ../webrick-dsc/httpserver.rb Sun Mar 17 14:49:29 2002
@@ -26,6 +26,7 @@ module WEBrick
mount("/", HTTPServlet::FileHandler,
@config[:DocumentRoot], @config[:DirectoryListEnable])
end
+ @config[:Server] = self
end
def run(sock)
@@ -65,12 +66,17 @@ module WEBrick
path = req.path
servlet, options, script_name, path_info = search_servlet(path)
raise HTTPStatus::NotFound, "`#{path}' not found." unless servlet
- if servlet.require_path_info? && path_info.empty?
- res.set_redirect(HTTPStatus::MovedPermanently, path + "/")
- end
- req.script_name = script_name
- req.path_info = path_info
- si = servlet.get_instance(@config, *options)
+ if (!servlet.respond_to?("service"))
+ if servlet.require_path_info? && path_info.empty?
+ res.set_redirect(HTTPStatus::MovedPermanently, path + "/")
+ end
+ si = servlet.get_instance(@config, *options)
+ else
+ si = servlet
+ si.setConfig(@config)
+ end
+ req.script_name = script_name
+ req.path_info = path_info
si.service(req, res)
end
diff -upr ./httpservlet/abstract.rb ../webrick-dsc/httpservlet/abstract.rb
--- ./httpservlet/abstract.rb Mon Mar 18 16:48:03 2002
+++ ../webrick-dsc/httpservlet/abstract.rb Sun Mar 17 14:48:11 2002
@@ -12,6 +12,7 @@ require 'webrick/htmlutils'
require 'webrick/httputils'
require 'webrick/httpstatus'
require 'webrick/httpdate'
+require 'webrick/requestdispatcher'
module WEBrick
module HTTPServlet
@@ -30,11 +31,20 @@ module WEBrick
self.new(config, *options)
end
- def initialize(config, *options)
+ def setConfig(config)
+ return if config==nil
@config = config
@logger = config[:Logger]
+ @server = config[:Server]
+ end
+ def initialize(config, *options)
+ setConfig(config)
@options = options
end
+
+ def get_request_dispatcher(url)
+ return RequestDispatcher.new(@config,url,@server)
+ end
def service(req, res)
method_name = "do_" + req.request_method.gsub(/-/, "_")
Only in ../webrick-dsc: requestdispatcher.rb