about summary refs log tree commit homepage
path: root/lib/rainbows/event_machine
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-07-19 10:10:05 +0000
committerEric Wong <normalperson@yhbt.net>2010-07-19 17:04:35 -0700
commit0cd65fa1e01be369b270c72053cf21a3d6bcb45f (patch)
tree7ae76d0860f740838faa9cb5172b100b7a58a35c /lib/rainbows/event_machine
parented14b9bdbb35fa18dc283ba2d048a33d10759b2d (diff)
downloadrainbows-0cd65fa1e01be369b270c72053cf21a3d6bcb45f.tar.gz
Some middlewares such as Clogger rely on wrapping the body
having the close method called on it for logging.
Diffstat (limited to 'lib/rainbows/event_machine')
-rw-r--r--lib/rainbows/event_machine/response_pipe.rb7
1 files changed, 4 insertions, 3 deletions
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