From 3495d59763e6159975debf32728dc53fc41c5ea1 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 27 Dec 2010 20:25:39 -0800 Subject: several response body#close fixes 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. --- lib/rainbows/revactor/body.rb | 3 +++ 1 file changed, 3 insertions(+) (limited to 'lib/rainbows/revactor') diff --git a/lib/rainbows/revactor/body.rb b/lib/rainbows/revactor/body.rb index ad2bc55..7bfb5de 100644 --- a/lib/rainbows/revactor/body.rb +++ b/lib/rainbows/revactor/body.rb @@ -8,6 +8,7 @@ module Rainbows::Revactor::Body if IO.method_defined?(:sendfile_nonblock) def write_body_file(client, body, range) + body = body_to_io(body) sock = client.instance_variable_get(:@_io) pfx = Revactor::TCP::Socket === client ? :tcp : :unix write_complete = T[:"#{pfx}_write_complete", client] @@ -29,6 +30,8 @@ module Rainbows::Revactor::Body rescue EOFError break end while (count -= n) > 0 + ensure + close_if_private(body) end else ALIASES[:write_body] = :write_body_each -- cgit v1.2.3-24-ge0c7