diff options
Diffstat (limited to 'lib/unicorn/tee_input.rb')
-rw-r--r-- | lib/unicorn/tee_input.rb | 24 |
1 files changed, 5 insertions, 19 deletions
diff --git a/lib/unicorn/tee_input.rb b/lib/unicorn/tee_input.rb index 9e66837..ac9638d 100644 --- a/lib/unicorn/tee_input.rb +++ b/lib/unicorn/tee_input.rb @@ -15,30 +15,16 @@ require 'tempfile' module Unicorn class TeeInput - def initialize - @rd = @wr = @size = @input = nil - setup - end - - def setup - @tmp = tmp = Tempfile.new(nil) - @rd.close if @rd - @rd = File.open(tmp.path, 'wb+') - @wr.close if @wr - @wr = File.open(tmp.path, 'wb') + def initialize(input, size = nil, buffer = nil) + @wr = Tempfile.new(nil) + @wr.binmode + @rd = File.open(@wr.path, 'rb') + @wr.unlink @rd.sync = @wr.sync = true - tmp.close! - end - - def reopen(input, size = nil, buffer = nil) - @rd.seek(0) - @wr.seek(0) - @rd.truncate(0) # truncate read to flush luserspace read buffers @wr.write(buffer) if buffer @input = input @size = size # nil if chunked - self end def consume |