about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-04-23 18:35:26 -0700
committerEric Wong <normalperson@yhbt.net>2009-04-23 18:38:41 -0700
commit8ca2d34df19ed7802a59bdedb78e2261487c064c (patch)
tree652e4c7bccd646ec0c71ccec46916c1b00b871a2 /lib
parentf2e90a9f15efda1abc87cde00bb341fdf3368985 (diff)
downloadunicorn-8ca2d34df19ed7802a59bdedb78e2261487c064c.tar.gz
StringIO.new(partial_body) does not update the offset for new
writes.  So instead create the StringIO object and then syswrite
to it and try to follow the same code path used by large uploads
which use Tempfiles.
Diffstat (limited to 'lib')
-rw-r--r--lib/unicorn/http_request.rb13
1 files changed, 4 insertions, 9 deletions
diff --git a/lib/unicorn/http_request.rb b/lib/unicorn/http_request.rb
index a3a1d4d..399aee5 100644
--- a/lib/unicorn/http_request.rb
+++ b/lib/unicorn/http_request.rb
@@ -87,15 +87,10 @@ module Unicorn
       remain = content_length - http_body.length
 
       # must read more data to complete body
-      if remain < Const::MAX_BODY
-        # small body, just use that
-        @body = StringIO.new(http_body)
-      else # huge body, put it in a tempfile
-        @body = Tempfile.new(Const::UNICORN_TMP_BASE)
-        @body.binmode
-        @body.sync = true
-        @body.syswrite(http_body)
-      end
+      @body = remain < Const::MAX_BODY ? StringIO.new : Tempfile.new('')
+      @body.binmode
+      @body.sync = true
+      @body.syswrite(http_body)
 
       # Some clients (like FF1.0) report 0 for body and then send a body.
       # This will probably truncate them but at least the request goes through