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:

add 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/trunk@7033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
gotoyuzo 2004-10-12 12:26:39 +00:00
parent 90b337ce37
commit 385edf1e5c
6 changed files with 165 additions and 31 deletions

View file

@ -63,6 +63,24 @@ module WEBrick
@header[field.downcase] = value.to_s
end
def content_length
if len = self['content-length']
return Integer(len)
end
end
def content_length=(len)
self['content-length'] = len.to_s
end
def content_type
self['content-type']
end
def content_type=(type)
self['content-type'] = type
end
def each
@header.each{|k, v| yield(k, v) }
end
@ -250,7 +268,7 @@ module WEBrick
_write_data(socket, "0#{CRLF}#{CRLF}")
else
size = @header['content-length'].to_i
_send_file(socket, @body, 0, size.to_i)
_send_file(socket, @body, 0, size)
@sent_size = size
end
@body.close