about summary refs log tree commit homepage
path: root/lib/yahns/config.rb
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2013-10-19 01:50:42 +0000
committerEric Wong <normalperson@yhbt.net>2013-10-19 01:51:29 +0000
commit2377d5a1cafa518313b0b597e4c3af65bb57f887 (patch)
treea1d26cf33782e580f0d98641d9a3889975434ba6 /lib/yahns/config.rb
parentf89ee896e14bfa97179f3773d303dd0a1bdcf971 (diff)
downloadyahns-2377d5a1cafa518313b0b597e4c3af65bb57f887.tar.gz
This is mostly code imported from Rainbows! (so GPLv2+).  This should
implement everything necessary to prevent clients from DoS-ing us with
overly large bodies.  The default is 1M (same as Rainbows! and nginx).

Yahns::MaxBody may become part of the public API (as the equivalent is
in Rainbows!), since it makes more sense in the rackup (config.ru) file
(since it's endpoint-specific).  However, that's confusing as
Yahns::MaxBody only works when input_buffering is :lazy or false, and
not when it is true (preread).
Diffstat (limited to 'lib/yahns/config.rb')
-rw-r--r--lib/yahns/config.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/yahns/config.rb b/lib/yahns/config.rb
index 4861f3e..61de74e 100644
--- a/lib/yahns/config.rb
+++ b/lib/yahns/config.rb
@@ -285,7 +285,6 @@ class Yahns::Config # :nodoc:
   {
     # config name, minimum value
     client_body_buffer_size: 1,
-    client_max_body_size: 0,
     client_header_buffer_size: 1,
     client_max_header_size: 1,
     client_timeout: 0,
@@ -298,6 +297,12 @@ class Yahns::Config # :nodoc:
     )
   end
 
+  def client_max_body_size(val)
+    var = _check_in_block(:app, :client_max_body_size)
+    val = _check_int(var, val, 0) if val != nil
+    @block.ctx.__send__("#{var}=", val)
+  end
+
   def input_buffering(val)
     var = _check_in_block(:app, :input_buffering)
     ok = [ :lazy, true, false ]