mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/cgi: check by Encoding.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
da861d79b7
commit
738515d12b
5 changed files with 16 additions and 19 deletions
|
@ -32,7 +32,7 @@ class MultiPart
|
|||
def initialize(boundary=nil)
|
||||
@boundary = boundary || create_boundary()
|
||||
@buf = ''
|
||||
@buf.force_encoding("ascii-8bit") if RUBY_VERSION>="1.9"
|
||||
@buf.force_encoding(::Encoding::ASCII_8BIT) if defined?(::Encoding)
|
||||
end
|
||||
attr_reader :boundary
|
||||
|
||||
|
@ -44,11 +44,8 @@ class MultiPart
|
|||
buf << "Content-Disposition: form-data: name=\"#{name}\"#{s}\r\n"
|
||||
buf << "Content-Type: #{content_type}\r\n" if content_type
|
||||
buf << "\r\n"
|
||||
if RUBY_VERSION>="1.9"
|
||||
buf << value.dup.force_encoding("ASCII-8BIT")
|
||||
else
|
||||
buf << value
|
||||
end
|
||||
value = value.dup.force_encoding(::Encoding::ASCII_8BIT) if defined?(::Encoding)
|
||||
buf << value
|
||||
buf << "\r\n"
|
||||
return self
|
||||
end
|
||||
|
@ -192,7 +189,7 @@ class CGIMultipartTest < Test::Unit::TestCase
|
|||
{:name=>'image1', :value=>_read('small.png'),
|
||||
:filename=>'small.png', :content_type=>'image/png'}, # small image
|
||||
]
|
||||
@data[1][:value].force_encoding("UTF-8") if RUBY_VERSION>="1.9"
|
||||
@data[1][:value].force_encoding(::Encoding::UTF_8) if defined?(::Encoding)
|
||||
@expected_class = StringIO
|
||||
_test_multipart()
|
||||
end
|
||||
|
@ -208,7 +205,7 @@ class CGIMultipartTest < Test::Unit::TestCase
|
|||
{:name=>'image1', :value=>_read('large.png'),
|
||||
:filename=>'large.png', :content_type=>'image/png'}, # large image
|
||||
]
|
||||
@data[1][:value].force_encoding("UTF-8") if RUBY_VERSION>="1.9"
|
||||
@data[1][:value].force_encoding(::Encoding::UTF_8) if defined?(::Encoding)
|
||||
@expected_class = Tempfile
|
||||
_test_multipart()
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue