From 704f843054f3ca32941d42972a1c7d1b144d06ad Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 9 May 2011 04:39:54 +0000 Subject: configurator: move validation logic over There's actually no reason we can't have these methods in Rainbows::Configurator where it's easier to document nowadays. --- lib/rainbows/max_body.rb | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lib/rainbows/max_body.rb') 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, -- cgit v1.2.3-24-ge0c7