lib/rainbows/max_body.rb in rainbows-4.7.0 vs lib/rainbows/max_body.rb in rainbows-5.0.0
- old
+ new
@@ -46,23 +46,18 @@
raise ArgumentError, "limit not an Integer"
end
@app, @limit = app, limit
end
- # :stopdoc:
- RACK_INPUT = "rack.input".freeze
- CONTENT_LENGTH = "CONTENT_LENGTH"
- HTTP_TRANSFER_ENCODING = "HTTP_TRANSFER_ENCODING"
-
# 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]
+ len = env['CONTENT_LENGTH']
if len && len.to_i > @limit
return err
- elsif /\Achunked\z/i =~ env[HTTP_TRANSFER_ENCODING]
+ elsif /\Achunked\z/i =~ env['HTTP_TRANSFER_ENCODING']
limit_input!(env)
end
@app.call(env)
end || err
end
@@ -87,12 +82,12 @@
def err # :nodoc:
[ 413, { 'Content-Length' => '0', 'Content-Type' => 'text/plain' }, [] ]
end
def limit_input!(env)
- input = env[RACK_INPUT]
+ input = env['rack.input']
klass = input.respond_to?(:rewind) ? RewindableWrapper : Wrapper
- env[RACK_INPUT] = klass.new(input, @limit)
+ env['rack.input'] = klass.new(input, @limit)
end
# :startdoc:
end
require 'rainbows/max_body/wrapper'