summaryrefslogtreecommitdiff
path: root/test/cgi
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-05 02:34:17 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-11-05 02:34:17 +0000
commit0ba4526d06e16ee496c581d7cf5a9fee801b3109 (patch)
treea32222b2a628f798712d4a7ed968b3732c791fd1 /test/cgi
parent0ba78cb2f79530abf433b008a23778c7468d6af4 (diff)
* lib/cgi/core.rb: check if Tempfile is defined before use it.
* lib/cgi/core.rb: remove tempfiles only if tempfiles exist git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37473 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/cgi')
-rw-r--r--test/cgi/test_cgi_multipart.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/cgi/test_cgi_multipart.rb b/test/cgi/test_cgi_multipart.rb
index 62fcc8b..ea40535 100644
--- a/test/cgi/test_cgi_multipart.rb
+++ b/test/cgi/test_cgi_multipart.rb
@@ -2,6 +2,7 @@ require 'test/unit'
require 'cgi'
require 'tempfile'
require 'stringio'
+require_relative '../ruby/envutil'
##
@@ -332,6 +333,34 @@ class CGIMultipartTest < Test::Unit::TestCase
cgi['file'].unlink if cgi['file'].kind_of? Tempfile
end
+ def test_cgi_multipart_without_tempfile
+ assert_in_out_err([], <<-'EOM')
+ require 'cgi'
+ require 'stringio'
+ ENV['REQUEST_METHOD'] = 'POST'
+ ENV['CONTENT_TYPE'] = 'multipart/form-data; boundary=foobar1234'
+ body = <<-BODY
+--foobar1234
+Content-Disposition: form-data: name=\"name1\"
+
+value1
+--foobar1234
+Content-Disposition: form-data: name=\"file1\"; filename=\"file1.html\"
+Content-Type: text/html
+
+<html>
+<body><p>Hello</p></body>
+</html>
+
+--foobar1234--
+BODY
+ body.gsub!(/\n/, "\r\n")
+ ENV['CONTENT_LENGTH'] = body.size.to_s
+ $stdin = StringIO.new(body)
+ CGI.new
+ EOM
+ end
+
###
self.instance_methods.each do |method|