diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-12-27 20:25:39 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-12-28 17:12:28 -0800 |
commit | 3495d59763e6159975debf32728dc53fc41c5ea1 (patch) | |
tree | 949415250af66075cc9ca98040a85ddc2ad84380 /lib/rainbows/fiber | |
parent | 53afe0b23fc67c5b25541cddbd68f905c649e756 (diff) | |
download | rainbows-3495d59763e6159975debf32728dc53fc41c5ea1.tar.gz |
Some middlewares require the Rack env to be preserved all the way through to close, so we'll ensure all request models preserve it. We also need to better response body wrappers/proxies always get fired properly when returning. IO.copy_stream and "sendfile" gem users could hit cases where wrappers did not fire properly.
Diffstat (limited to 'lib/rainbows/fiber')
-rw-r--r-- | lib/rainbows/fiber/body.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/rainbows/fiber/body.rb b/lib/rainbows/fiber/body.rb index 0fe2ec6..29926c6 100644 --- a/lib/rainbows/fiber/body.rb +++ b/lib/rainbows/fiber/body.rb @@ -13,7 +13,7 @@ module Rainbows::Fiber::Body # :nodoc: # the sendfile 1.0.0+ gem includes IO#sendfile_nonblock if IO.method_defined?(:sendfile_nonblock) def write_body_file(client, body, range) - sock, n = client.to_io, nil + sock, n, body = client.to_io, nil, body_to_io(body) offset, count = range ? range : [ 0, body.stat.size ] begin offset += (n = sock.sendfile_nonblock(body, offset, count)) @@ -23,6 +23,8 @@ module Rainbows::Fiber::Body # :nodoc: rescue EOFError break end while (count -= n) > 0 + ensure + close_if_private(body) end else ALIASES[:write_body] = :write_body_each |