diff options
author | wakou <wakou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-05-30 00:21:05 +0000 |
---|---|---|
committer | wakou <wakou@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2002-05-30 00:21:05 +0000 |
commit | e60d6bef79faf06465408e9599e9185d32a72f26 (patch) | |
tree | 33bdee2c144cf4990f1982b3d1ed39cdd614d1a0 /lib | |
parent | 2c631db5f935adb7db19b8ff8c5ea77dc6e176d7 (diff) |
* lib/cgi.rb: if StringIO is usable then use it.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_6@2505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/cgi.rb | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/cgi.rb b/lib/cgi.rb index 13fd5bddfd..836fdf2a4d 100644 --- a/lib/cgi.rb +++ b/lib/cgi.rb @@ -70,8 +70,7 @@ cgi.params is a hash. values[0].original_filename # <== original filename of values[0] values[0].content_type # <== content_type of values[0] -and values[0] has Tempfile class methods. -(Tempfile class object has File class methods) +and values[0] has StringIO or Tempfile class methods. === GET COOKIE VALUES @@ -792,11 +791,20 @@ convert string charset, and set language to "ja". raise EOFError, "bad content body" end - require "tempfile" - until -1 == content_length head = nil - body = Tempfile.new("CGI") + if 10240 < content_length + require "tempfile" + body = Tempfile.new("CGI") + else + begin + require "stringio" if not defined? StringIO + body = StringIO.new + rescue LoadError + require "tempfile" + body = Tempfile.new("CGI") + end + end body.binmode until head and /#{boundary}(?:#{EOL}|--)/n.match(buf) |