From 0cd65fa1e01be369b270c72053cf21a3d6bcb45f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 19 Jul 2010 10:10:05 +0000 Subject: ensure stream response bodies get closed Some middlewares such as Clogger rely on wrapping the body having the close method called on it for logging. --- lib/rainbows/event_machine/response_pipe.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/rainbows/event_machine') diff --git a/lib/rainbows/event_machine/response_pipe.rb b/lib/rainbows/event_machine/response_pipe.rb index 88d6e5a..7d4988a 100644 --- a/lib/rainbows/event_machine/response_pipe.rb +++ b/lib/rainbows/event_machine/response_pipe.rb @@ -5,8 +5,8 @@ module Rainbows::EventMachine::ResponsePipe # so a single buffer for all clients will work safely BUF = '' - def initialize(client, alive) - @client, @alive = client, alive + def initialize(client, alive, body) + @client, @alive, @body = client, alive, body end def notify_readable @@ -23,6 +23,7 @@ module Rainbows::EventMachine::ResponsePipe def unbind @client.quit unless @alive - @io.close + @body.close if @body.respond_to?(:close) + @io.close unless @io.closed? end end -- cgit v1.2.3-24-ge0c7