From 76cae3b05f8fd67cb98416fa210e137d0c223ea1 Mon Sep 17 00:00:00 2001 From: wakou Date: Thu, 30 May 2002 00:21:05 +0000 Subject: * lib/cgi.rb: if StringIO is usable then use it. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@2505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ lib/cgi.rb | 18 +++++++++++++----- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0bf8a7a98..aa7a31852 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Thu May 30 09:16:36 2002 Wakou Aoyama + + * lib/cgi.rb: if StringIO is usable then use it. + Wed May 29 18:55:47 2002 KONISHI Hiromasa * function renames my* and win32_* to rb_w32_* in win32/win32.c diff --git a/lib/cgi.rb b/lib/cgi.rb index 13fd5bddf..836fdf2a4 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) -- cgit