diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-05-03 15:19:53 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-05-03 15:19:53 -0700 |
commit | 9f1131f5972ba90c1c54c76cc97633447142b307 (patch) | |
tree | c5ee918bfea67ffcd77b5b90ee2191ec2a5df129 /lib/rainbows/http_server.rb | |
parent | 1f3de8f8940fc7805c54d3d27e2074632ab5a0b0 (diff) | |
download | rainbows-9f1131f5972ba90c1c54c76cc97633447142b307.tar.gz |
Since Rainbows! is supported when exposed directly to the Internet, administrators may want to limit the amount of data a user may upload in a single request body to prevent a denial-of-service via disk space exhaustion. This amount may be specified in bytes, the default limit being 1024*1024 bytes (1 megabyte). To override this default, a user may specify `client_max_body_size' in the Rainbows! block of their server config file: Rainbows! do client_max_body_size 10 * 1024 * 1024 end Clients that exceed the limit will get a "413 Request Entity Too Large" response if the request body is too large and the connection will close. For chunked requests, we have no choice but to interrupt during the client upload since we have no prior knowledge of the request body size.
Diffstat (limited to 'lib/rainbows/http_server.rb')
-rw-r--r-- | lib/rainbows/http_server.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/rainbows/http_server.rb b/lib/rainbows/http_server.rb index ea2e23f..50231ff 100644 --- a/lib/rainbows/http_server.rb +++ b/lib/rainbows/http_server.rb @@ -85,6 +85,18 @@ module Rainbows raise ArgumentError, "keepalive must be a non-negative Integer" G.kato = nr end + + def client_max_body_size(nr) + err = "client_max_body_size must be nil or a non-negative Integer" + case nr + when nil + when Integer + nr >= 0 or raise ArgumentError, err + else + raise ArgumentError, err + end + Rainbows.max_bytes = nr + end end end |