max_body.rb

Path: lib/rainbows/max_body.rb
Last Update: Sat Feb 23 07:12:54 +0000 2019

Middleware used to enforce client_max_body_size for TeeInput users.

There is no need to configure this middleware manually, it will automatically be configured for you based on the client_max_body_size setting.

For more fine-grained control, you may also define it per-endpoint in your Rack config.ru like this:

       map "/limit_1M" do
         use Rainbows::MaxBody, 1024*1024
         run MyApp
       end
       map "/limit_10M" do
         use Rainbows::MaxBody, 1024*1024*10
         run MyApp
       end

This is only compatible with concurrency models that expose a streaming "rack.input" to the Rack application. Thus it is NOT compatible with any of the following as they fully buffer the request body before the application dispatch:

  • :Coolio
  • :CoolioThreadPool
  • :CoolioThreadSpawn
  • :Epoll
  • :EventMachine
  • :NeverBlock
  • :Rev
  • :RevThreadPool
  • :RevThreadSpawn
  • :XEpoll

However, the global Rainbows::Configurator#client_max_body_size is compatible with all concurrency models \Rainbows! supports.

Required files

rainbows/max_body/wrapper   rainbows/max_body/rewindable_wrapper  

[Validate]