1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* lib/webrick/config.rb (WEBrick::Config::General): add default values:

- WEBrick::Config[:DoNotReverseLookup]
  - WEBrick::Config[:RequestCallback] (it used as an alias of
    :RequestHandler in WEBrick::HTTPServer#run)
  - WEBrick::Config::FileHandler[:AcceptableLanguages]

* lib/webrick/httpservlet/filehandler.rb
  (WEBrick::HTTPServlet::FileHandler#set_filename): search files
  having suffix of language-name which Accept-Language header field
  includes if :AcceptableLanguages options is present.

* lib/webrick/httpservlet/filehandler.rb
  (WEBrick::HTTPServlet::FileHandler#get_servlet): new method to
  search servlet correspond to the suffix of filename.

* lib/webrick/httprequest.rb: add attributes access methods: accept,
  accept_charset, accept_encoding, accept_language, content_length
  and content_type.

* lib/webrick/httpresponse.rb: add attribute access methods:
  content_length, content_length=, content_type and content_type=.

* lib/webrick/httputils.rb (WEBrick::HTTPUtils.mime_types):
  use the second suffix to detect media type. (the first suffix
  may be a language name.)

* lib/webrick/httputils.rb (WEBrick::HTTPUtils.parse_qvalues):
  add method to parse Accept header field. it returns an Array of
  values sorted by the qvalues.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7056 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
gotoyuzo 2004-10-17 17:13:04 +00:00
parent f93f318f77
commit a79c87e333
6 changed files with 175 additions and 34 deletions

View file

@ -32,6 +32,8 @@ module WEBrick
# Header and entity body
attr_reader :raw_header, :header, :cookies
attr_reader :accept, :accept_charset
attr_reader :accept_encoding, :accept_language
# Misc
attr_accessor :user
@ -56,6 +58,10 @@ module WEBrick
@raw_header = Array.new
@header = nil
@cookies = []
@accept = []
@accept_charset = []
@accept_encoding = []
@accept_language = []
@body = ""
@addr = @peeraddr = nil
@ -83,6 +89,10 @@ module WEBrick
@header['cookie'].each{|cookie|
@cookies += Cookie::parse(cookie)
}
@accept = HTTPUtils.parse_qvalues(self['accept'])
@accept_charset = HTTPUtils.parse_qvalues(self['accept-charset'])
@accept_encoding = HTTPUtils.parse_qvalues(self['accept-encoding'])
@accept_language = HTTPUtils.parse_qvalues(self['accept-language'])
end
return if @request_method == "CONNECT"
return if @unparsed_uri == "*"
@ -124,6 +134,14 @@ module WEBrick
@query
end
def content_length
return Integer(self['content-length'])
end
def content_type
return self['content-type']
end
def [](header_name)
if @header
value = @header[header_name.downcase]