diff options
Diffstat (limited to 'lib/webrick/httpservlet/filehandler.rb')
| -rw-r--r-- | lib/webrick/httpservlet/filehandler.rb | 49 |
1 files changed, 1 insertions, 48 deletions
diff --git a/lib/webrick/httpservlet/filehandler.rb b/lib/webrick/httpservlet/filehandler.rb index d8c66dfdc3..daad8abd27 100644 --- a/lib/webrick/httpservlet/filehandler.rb +++ b/lib/webrick/httpservlet/filehandler.rb @@ -18,29 +18,12 @@ require 'webrick/httpstatus' module WEBrick module HTTPServlet - ## - # Servlet for serving a single file. You probably want to use the - # FileHandler servlet instead as it handles directories and fancy indexes. - # - # Example: - # - # server.mount('/my_page.txt', WEBrick::HTTPServlet::DefaultFileHandler, - # '/path/to/my_page.txt') - # - # This servlet handles If-Modified-Since and Range requests. - class DefaultFileHandler < AbstractServlet - - ## - # Creates a DefaultFileHandler instance for the file at +local_path+. - def initialize(server, local_path) super(server, local_path) @local_path = local_path end - # :stopdoc: - def do_GET(req, res) st = File::stat(@local_path) mtime = st.mtime @@ -140,46 +123,19 @@ module WEBrick last = filesize - 1 if last >= filesize return first, last end - - # :startdoc: end - ## - # Serves a directory including fancy indexing and a variety of other - # options. - # - # Example: - # - # server.mount '/assets', WEBrick::FileHandler, '/path/to/assets' - class FileHandler < AbstractServlet - HandlerTable = Hash.new # :nodoc: - - ## - # Allow custom handling of requests for files with +suffix+ by class - # +handler+ + HandlerTable = Hash.new def self.add_handler(suffix, handler) HandlerTable[suffix] = handler end - ## - # Remove custom handling of requests for files with +suffix+ - def self.remove_handler(suffix) HandlerTable.delete(suffix) end - ## - # Creates a FileHandler servlet on +server+ that serves files starting - # at directory +root+ - # - # +options+ may be a Hash containing keys from - # WEBrick::Config::FileHandler or +true+ or +false+. - # - # If +options+ is true or false then +:FancyIndexing+ is enabled or - # disabled respectively. - def initialize(server, root, options={}, default=Config::FileHandler) @config = server.config @logger = @config[:Logger] @@ -190,8 +146,6 @@ module WEBrick @options = default.dup.update(options) end - # :stopdoc: - def service(req, res) # if this class is mounted on "/" and /~username is requested. # we're going to override path informations before invoking service. @@ -480,7 +434,6 @@ module WEBrick _end_of_html_ end - # :startdoc: end end end |
