about summary refs log tree commit homepage
path: root/lib/rainbows/revactor.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-12-07 12:11:51 -0800
committerEric Wong <normalperson@yhbt.net>2010-12-08 13:32:44 -0800
commit1562a19a021a72a78ba495328d2d37ba0dc83b8c (patch)
treee86a23ed6484678936d57c1794980609069eafd0 /lib/rainbows/revactor.rb
parentb4835c6d542c6369f2523ab68fc41b0202d7c6dc (diff)
downloadrainbows-1562a19a021a72a78ba495328d2d37ba0dc83b8c.tar.gz
Large uploads behave differently with regard to buffering,
and there were bugs in the way the Rev and Revactor backends
handled uploads.
Diffstat (limited to 'lib/rainbows/revactor.rb')
-rw-r--r--lib/rainbows/revactor.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/rainbows/revactor.rb b/lib/rainbows/revactor.rb
index 59f37b0..51f6c1f 100644
--- a/lib/rainbows/revactor.rb
+++ b/lib/rainbows/revactor.rb
@@ -46,13 +46,14 @@ module Rainbows::Revactor
     alive = false
 
     begin
+      ts = nil
       until env = hp.parse
         buf << client.read(*rd_args)
       end
 
       env[CLIENT_IO] = client
       env[RACK_INPUT] = 0 == hp.content_length ?
-               NULL_IO : Unicorn::TeeInput.new(TeeSocket.new(client), hp)
+               NULL_IO : Unicorn::TeeInput.new(ts = TeeSocket.new(client), hp)
       env[REMOTE_ADDR] = remote_addr
       status, headers, body = app.call(env.update(RACK_DEFAULTS))
 
@@ -68,6 +69,7 @@ module Rainbows::Revactor
         alive = hp.next? && G.alive && G.kato > 0
         headers[CONNECTION] = alive ? KEEP_ALIVE : CLOSE
         client.write(response_header(status, headers))
+        alive && ts and buf << ts.leftover
       end
       write_body(client, body, range)
     end while alive
@@ -155,6 +157,10 @@ module Rainbows::Revactor
       @socket, @rbuf = socket, IO::Buffer.new
     end
 
+    def leftover
+      @rbuf.read
+    end
+
     # Revactor socket reads always return an unspecified amount,
     # sometimes too much
     def kgio_read(length, dst = "")