diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-12-09 03:39:03 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-12-09 03:41:25 +0000 |
commit | 71716672752e573ff15002aaefd6e8ba8c6b6cb6 (patch) | |
tree | 6812276bfbb7dc842ffa5a9a46a8b49243a373cb /lib/unicorn/tee_input.rb | |
parent | 9d80b009a3cb795530ad23263f4eb525880e79dc (diff) | |
download | unicorn-71716672752e573ff15002aaefd6e8ba8c6b6cb6.tar.gz |
Since modern machines have more memory these days and clients are sending more data, avoiding potentially slow filesystem operations for larger uploads can be useful for some applications.
Diffstat (limited to 'lib/unicorn/tee_input.rb')
-rw-r--r-- | lib/unicorn/tee_input.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/unicorn/tee_input.rb b/lib/unicorn/tee_input.rb index 53f6ebf..a038a84 100644 --- a/lib/unicorn/tee_input.rb +++ b/lib/unicorn/tee_input.rb @@ -16,12 +16,24 @@ class Unicorn::TeeInput < Unicorn::StreamInput # resorting to a temporary file. Default is 112 kilobytes. @@client_body_buffer_size = Unicorn::Const::MAX_BODY + # sets the maximum size of request bodies to buffer in memory, + # amounts larger than this are buffered to the filesystem + def self.client_body_buffer_size=(bytes) + @@client_body_buffer_size = bytes + end + + # returns the maximum size of request bodies to buffer in memory, + # amounts larger than this are buffered to the filesystem + def self.client_body_buffer_size + @@client_body_buffer_size + end + # Initializes a new TeeInput object. You normally do not have to call # this unless you are writing an HTTP server. def initialize(socket, request) @len = request.content_length super - @tmp = @len && @len < @@client_body_buffer_size ? + @tmp = @len && @len <= @@client_body_buffer_size ? StringIO.new("") : Unicorn::TmpIO.new end |