mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/webrick/accesslog.rb: Improved WEBrick documentation.
* lib/webrick/cgi.rb: ditto. * lib/webrick/config.rb: ditto. * lib/webrick/cookie.rb: ditto. * lib/webrick/httpauth/authenticator.rb: ditto. * lib/webrick/httpauth/basicauth.rb: ditto. * lib/webrick/httpauth/digestauth.rb: ditto. * lib/webrick/httpproxy.rb: ditto. * lib/webrick/httprequest.rb: ditto. * lib/webrick/httpresponse.rb: ditto. * lib/webrick/https.rb: ditto. * lib/webrick/httpserver.rb: ditto. * lib/webrick/httpservlet/cgihandler.rb: ditto. * lib/webrick/httpservlet/filehandler.rb: ditto. * lib/webrick/httpservlet/prochandler.rb: ditto. * lib/webrick/httputils.rb: ditto. * lib/webrick/httpversion.rb: ditto. * lib/webrick/log.rb: ditto. * lib/webrick/server.rb: ditto. * lib/webrick/ssl.rb: ditto. * lib/webrick/utils.rb: ditto. * lib/webrick/version.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38945 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
89232d1dd9
commit
28afe277a8
23 changed files with 839 additions and 85 deletions
|
@ -18,12 +18,29 @@ 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
|
||||
|
@ -123,13 +140,20 @@ module WEBrick
|
|||
last = filesize - 1 if last >= filesize
|
||||
return first, last
|
||||
end
|
||||
|
||||
# :startdoc:
|
||||
end
|
||||
|
||||
##
|
||||
# Serves files from a directory
|
||||
# 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
|
||||
HandlerTable = Hash.new # :nodoc:
|
||||
|
||||
##
|
||||
# Allow custom handling of requests for files with +suffix+ by class
|
||||
|
@ -150,19 +174,8 @@ module WEBrick
|
|||
# Creates a FileHandler servlet on +server+ that serves files starting
|
||||
# at directory +root+
|
||||
#
|
||||
# If +options+ is a Hash the following keys are allowed:
|
||||
#
|
||||
# :AcceptableLanguages:: Array of languages allowed for accept-language
|
||||
# :DirectoryCallback:: Allows preprocessing of directory requests
|
||||
# :FancyIndexing:: If true, show an index for directories
|
||||
# :FileCallback:: Allows preprocessing of file requests
|
||||
# :HandlerCallback:: Allows preprocessing of requests
|
||||
# :HandlerTable:: Maps file suffixes to file handlers.
|
||||
# DefaultFileHandler is used by default but any servlet
|
||||
# can be used.
|
||||
# :NondisclosureName:: Do not show files matching this array of globs
|
||||
# :UserDir:: Directory inside ~user to serve content from for /~user
|
||||
# requests. Only works if mounted on /
|
||||
# +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.
|
||||
|
@ -177,6 +190,8 @@ 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.
|
||||
|
@ -465,6 +480,7 @@ module WEBrick
|
|||
_end_of_html_
|
||||
end
|
||||
|
||||
# :startdoc:
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue