summaryrefslogtreecommitdiff
path: root/test/cgi
diff options
context:
space:
mode:
authorxibbar <xibbar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-10 04:29:49 +0000
committerxibbar <xibbar@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-06-10 04:29:49 +0000
commit5c99f241a0e8712e27fae013e2a6be46b136acf8 (patch)
tree1b85a7287b106ac11a445f64d1044451893d1b13 /test/cgi
parentf9a5335ed4f84e6e3ed23cb92966a36101d9d149 (diff)
downloadbundler-5c99f241a0e8712e27fae013e2a6be46b136acf8.tar.gz
* lib/cgi/core.rb: Provide a mechanism to specify the
max_multipart_length of multipart data. [Feature #8370] patch by Leif Eriksen <leif.eriksen.au@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46392 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/cgi')
-rw-r--r--test/cgi/test_cgi_multipart.rb27
1 files changed, 21 insertions, 6 deletions
diff --git a/test/cgi/test_cgi_multipart.rb b/test/cgi/test_cgi_multipart.rb
index 7461faab23..989ac7aba8 100644
--- a/test/cgi/test_cgi_multipart.rb
+++ b/test/cgi/test_cgi_multipart.rb
@@ -145,12 +145,14 @@ class CGIMultipartTest < Test::Unit::TestCase
$stdin = tmpfile
end
- def _test_multipart
+ def _test_multipart(cgi_options={})
caller(0).find {|s| s =~ /in `test_(.*?)'/ }
#testname = $1
#$stderr.puts "*** debug: testname=#{testname.inspect}"
_prepare(@data)
- cgi = RUBY_VERSION>="1.9" ? CGI.new(:accept_charset=>"UTF-8") : CGI.new
+ options = {:accept_charset=>"UTF-8"}
+ options.merge! cgi_options
+ cgi = RUBY_VERSION>="1.9" ? CGI.new(options) : CGI.new
expected_names = @data.collect{|hash| hash[:name] }.sort
assert_equal(expected_names, cgi.params.keys.sort)
threshold = 1024*10
@@ -243,16 +245,29 @@ class CGIMultipartTest < Test::Unit::TestCase
{:name=>'image1', :value=>_read('large.png'),
:filename=>'large.png', :content_type=>'image/png'}, # large image
]
- original = _set_const(CGI, :MAX_MULTIPART_LENGTH, 2 * 1024)
begin
ex = assert_raise(StandardError) do
- _test_multipart()
+ _test_multipart(:max_multipart_length=>2 * 1024) # set via simple scalar
+ end
+ assert_equal("too large multipart data.", ex.message)
+ ensure
+ end
+ end
+
+
+ def test_cgi_multipart_maxmultipartlength_lambda
+ @data = [
+ {:name=>'image1', :value=>_read('large.png'),
+ :filename=>'large.png', :content_type=>'image/png'}, # large image
+ ]
+ begin
+ ex = assert_raise(StandardError) do
+ _test_multipart(:max_multipart_length=>lambda{2*1024}) # set via lambda
end
assert_equal("too large multipart data.", ex.message)
ensure
- _set_const(CGI, :MAX_MULTIPART_LENGTH, original)
end
- end if CGI.const_defined?(:MAX_MULTIPART_LENGTH)
+ end
def test_cgi_multipart_maxmultipartcount