diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-05-03 17:56:00 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-05-03 17:56:00 -0700 |
commit | de3bcfe3ba9402bd510f7414df1763b6b99dae47 (patch) | |
tree | 180526ea73118ed9e3b0cc606684288991875b72 /lib/rainbows/max_body.rb | |
parent | 54cae80e543a6f4ca6456fe07b88aba867d215a6 (diff) | |
download | rainbows-de3bcfe3ba9402bd510f7414df1763b6b99dae47.tar.gz |
WAvoid mucking with Unicorn::TeeInput, since other apps may depend on that class, so we subclass it as Rainbows::TeeInput and modify as necessary in worker processes. For Revactor, remove the special-cased Rainbows::Revactor::TeeInput class and instead emulate readpartial for Revactor sockets instead.
Diffstat (limited to 'lib/rainbows/max_body.rb')
-rw-r--r-- | lib/rainbows/max_body.rb | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/lib/rainbows/max_body.rb b/lib/rainbows/max_body.rb index 71141c1..ca63ea4 100644 --- a/lib/rainbows/max_body.rb +++ b/lib/rainbows/max_body.rb @@ -7,7 +7,7 @@ module Rainbows # setting class MaxBody < Struct.new(:app) - # this is meant to be included in Unicorn::TeeInput (and derived + # this is meant to be included in Rainbows::TeeInput (and derived # classes) to limit body sizes module Limit Util = Unicorn::Util @@ -41,7 +41,7 @@ class MaxBody < Struct.new(:app) end def tee(length, dst) - rv = _tee(length, dst) + rv = super if rv && ((@max_body -= rv.size) < 0) # make HttpParser#keepalive? => false to force an immediate disconnect # after we write @@ -60,17 +60,10 @@ class MaxBody < Struct.new(:app) case G.server.use when :Rev, :EventMachine, :NeverBlock return - when :Revactor - Rainbows::Revactor::TeeInput - else - Unicorn::TeeInput - end.class_eval do - alias _tee tee # can't use super here :< - remove_method :tee - remove_method :initialize if G.server.use != :Revactor # FIXME CODE SMELL - include Limit end + TeeInput.class_eval { include Limit } + # force ourselves to the outermost middleware layer G.server.app = MaxBody.new(G.server.app) end |