about summary refs log tree commit homepage
path: root/lib/rainbows/max_body.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2011-05-09 04:39:54 +0000
committerEric Wong <normalperson@yhbt.net>2011-05-10 08:20:27 +0000
commit704f843054f3ca32941d42972a1c7d1b144d06ad (patch)
tree2e7fea212988a9a67b7cdfab3ef939a221448e65 /lib/rainbows/max_body.rb
parent598525843ee1d120fd9878011ca2b6328c2cf95f (diff)
downloadrainbows-704f843054f3ca32941d42972a1c7d1b144d06ad.tar.gz
There's actually no reason we can't have these methods
in Rainbows::Configurator where it's easier to document
nowadays.
Diffstat (limited to 'lib/rainbows/max_body.rb')
-rw-r--r--lib/rainbows/max_body.rb11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/rainbows/max_body.rb b/lib/rainbows/max_body.rb
index 33ba572..aedc9e9 100644
--- a/lib/rainbows/max_body.rb
+++ b/lib/rainbows/max_body.rb
@@ -21,8 +21,12 @@
 class Rainbows::MaxBody
 
   # This is automatically called when used with Rack::Builder#use
-  def initialize(app, limit = Rainbows.client_max_body_size)
-    Integer === limit or raise ArgumentError, "limit not an Integer"
+  def initialize(app, limit = nil)
+    case limit
+    when Integer, nil
+    else
+      raise ArgumentError, "limit not an Integer"
+    end
     @app, @limit = app, limit
   end
 
@@ -33,6 +37,7 @@ class Rainbows::MaxBody
 
   # our main Rack middleware endpoint
   def call(env)
+    @limit = Rainbows.server.client_max_body_size if nil == @limit
     catch(:rainbows_EFBIG) do
       len = env[CONTENT_LENGTH]
       if len && len.to_i > @limit
@@ -47,7 +52,7 @@ class Rainbows::MaxBody
   # this is called after forking, so it won't ever affect the master
   # if it's reconfigured
   def self.setup # :nodoc:
-    Rainbows.client_max_body_size or return
+    Rainbows.server.client_max_body_size or return
     case Rainbows.server.use
     when :Rev, :Coolio, :EventMachine, :NeverBlock,
          :RevThreadSpawn, :RevThreadPool,