* lib/open-uri.rb (OpenURI::Meta#meta_setup_encoding): setup encoding
by charset. (OpenURI::Meta#meta_add_field): call meta_setup_encoding when content-type. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15630 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2f12678bcf
commit
1f262b3ef4
@ -1,3 +1,10 @@
|
|||||||
|
Thu Feb 28 18:07:52 2008 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* lib/open-uri.rb (OpenURI::Meta#meta_setup_encoding): setup encoding
|
||||||
|
by charset.
|
||||||
|
(OpenURI::Meta#meta_add_field): call meta_setup_encoding when
|
||||||
|
content-type.
|
||||||
|
|
||||||
Thu Feb 28 15:29:12 2008 NARUSE, Yui <naruse@ruby-lang.org>
|
Thu Feb 28 15:29:12 2008 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* io.c (rb_io_getline_fast): scan coderange.
|
* io.c (rb_io_getline_fast): scan coderange.
|
||||||
|
@ -412,8 +412,27 @@ module OpenURI
|
|||||||
# The Hash keys are downcased for canonicalization.
|
# The Hash keys are downcased for canonicalization.
|
||||||
attr_reader :meta
|
attr_reader :meta
|
||||||
|
|
||||||
|
def meta_setup_encoding # :nodoc:
|
||||||
|
charset = self.charset
|
||||||
|
return unless charset
|
||||||
|
begin
|
||||||
|
enc = Encoding.find(charset)
|
||||||
|
rescue ArgumentError
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if self.respond_to? :force_encoding
|
||||||
|
self.force_encoding(enc)
|
||||||
|
elsif self.respond_to? :string
|
||||||
|
self.string.force_encoding(enc)
|
||||||
|
else # Tempfile
|
||||||
|
self.set_encoding enc
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def meta_add_field(name, value) # :nodoc:
|
def meta_add_field(name, value) # :nodoc:
|
||||||
@meta[name.downcase] = value
|
name = name.downcase
|
||||||
|
@meta[name] = value
|
||||||
|
meta_setup_encoding if name == 'content-type'
|
||||||
end
|
end
|
||||||
|
|
||||||
# returns a Time which represents Last-Modified field.
|
# returns a Time which represents Last-Modified field.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user