about summary refs log tree commit homepage
path: root/lib/rainbows/ev_core.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-12-09 17:14:04 -0800
committerEric Wong <normalperson@yhbt.net>2010-12-09 17:14:04 -0800
commit2bb3f8fd600bd0aabe5e4d7c3d1f99d745fc8f49 (patch)
treed497e2b91c4865c3cf8f1027f58e391165e2741a /lib/rainbows/ev_core.rb
parentaf3629e6bd88b5744016a1c6217c00c37ef5a376 (diff)
downloadrainbows-2bb3f8fd600bd0aabe5e4d7c3d1f99d745fc8f49.tar.gz
This is only needed for concurrency options that
do not use TeeInput, since TeeInput automatically
handles this for us.
Diffstat (limited to 'lib/rainbows/ev_core.rb')
-rw-r--r--lib/rainbows/ev_core.rb14
1 files changed, 11 insertions, 3 deletions
diff --git a/lib/rainbows/ev_core.rb b/lib/rainbows/ev_core.rb
index 46fdedf..6f1b5e5 100644
--- a/lib/rainbows/ev_core.rb
+++ b/lib/rainbows/ev_core.rb
@@ -108,8 +108,12 @@ module Rainbows::EvCore
     raise IOError, msg, []
   end
 
-  MAX_BODY = Unicorn::Const::MAX_BODY
   TmpIO = Unicorn::TmpIO
+
+  def io_for(bytes)
+    bytes <= CBB ? StringIO.new("") : TmpIO.new
+  end
+
   def mkinput
     max = Rainbows.max_bytes
     len = @hp.content_length
@@ -117,9 +121,13 @@ module Rainbows::EvCore
       if max && (len > max)
         err_413("Content-Length too big: #{len} > #{max}")
       end
-      len <= MAX_BODY ? StringIO.new("") : TmpIO.new
+      io_for(len)
     else
-      max ? CapInput.new(TmpIO.new, self) : TmpIO.new
+      max ? CapInput.new(io_for(max), self, max) : TmpIO.new
     end
   end
+
+  def self.setup
+    const_set :CBB, Unicorn::TeeInput.client_body_buffer_size
+  end
 end