mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/open-uri.rb (OpenURI::Redirect#initialize): call super to
initialize mesg. * lib/open-uri.rb (OpenURI::Meta#charset): call block to guess charset if block is given and charset is not given. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
068170e47a
commit
131c29ffff
2 changed files with 19 additions and 0 deletions
|
@ -1,3 +1,11 @@
|
|||
Thu May 15 18:44:31 2003 Tanaka Akira <akr@m17n.org>
|
||||
|
||||
* lib/open-uri.rb (OpenURI::Redirect#initialize): call super to
|
||||
initialize mesg.
|
||||
|
||||
* lib/open-uri.rb (OpenURI::Meta#charset): call block to guess charset
|
||||
if block is given and charset is not given.
|
||||
|
||||
Thu May 15 16:55:16 2003 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||
|
||||
* object.c (rb_mod_le): returns nil if two classes/modules are not
|
||||
|
|
|
@ -163,6 +163,7 @@ module OpenURI
|
|||
|
||||
class Redirect < StandardError # :nodoc:
|
||||
def initialize(uri)
|
||||
super("redirection to #{uri.to_s}")
|
||||
@uri = uri
|
||||
end
|
||||
attr_reader :uri
|
||||
|
@ -271,10 +272,20 @@ module OpenURI
|
|||
|
||||
# returns a charset parameter in Content-Type field.
|
||||
# It is downcased for canonicalization.
|
||||
#
|
||||
# If charset parameter is not given but a block is given,
|
||||
# the block is called and its result is returned.
|
||||
# It can be used to guess charset.
|
||||
#
|
||||
# If charset parameter and block is not given,
|
||||
# nil is returned except text type in HTTP.
|
||||
# In that case, "iso-8859-1" is returned as defined by RFC2616 3.7.1.
|
||||
def charset
|
||||
type, *parameters = content_type_parse
|
||||
if pair = parameters.assoc('charset')
|
||||
pair.last.downcase
|
||||
elsif block_given?
|
||||
yield
|
||||
elsif type && %r{\Atext/} =~ type &&
|
||||
@base_uri && @base_uri.scheme == 'http'
|
||||
"iso-8859-1" # RFC2616 3.7.1
|
||||
|
|
Loading…
Add table
Reference in a new issue