about summary refs log tree commit homepage
path: root/lib/rainbows/response/body.rb
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/response/body.rb
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/response/body.rb')
-rw-r--r--lib/rainbows/response/body.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/lib/rainbows/response/body.rb b/lib/rainbows/response/body.rb
index 0a2bb5d..9e36412 100644
--- a/lib/rainbows/response/body.rb
+++ b/lib/rainbows/response/body.rb
@@ -88,9 +88,11 @@ module Rainbows::Response::Body # :nodoc:
       ensure
         body.respond_to?(:close) && inp != body and body.close
     end
-  else
+  elsif method_defined?(:write_body_stream)
     def write_body_path(sock, body)
-      write_body_stream(sock, body_to_io(body))
+      write_body_stream(sock, inp = body_to_io(body))
+      ensure
+        body.respond_to?(:close) && inp != body and body.close
     end
   end