summary refs log tree commit homepage
path: root/lib/rainbows/event_machine.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-07-19 10:10:08 +0000
committerEric Wong <normalperson@yhbt.net>2010-07-19 17:04:39 -0700
commit9c8372c3a4972cacf0eb15ad85d34cb33293672e (patch)
tree1998fa98415c7331c56c06de69d06069fd55154b /lib/rainbows/event_machine.rb
parentfa4eb71b8208f7fc4148a7f8dd916c2e0cd1cc8a (diff)
We need to remember to close response bodies even if
a client aborts the connection, since body.close can
trigger interesting things like logging and such...
Diffstat (limited to 'lib/rainbows/event_machine.rb')
-rw-r--r--lib/rainbows/event_machine.rb11
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/rainbows/event_machine.rb b/lib/rainbows/event_machine.rb
index 3094284..8de02ea 100644
--- a/lib/rainbows/event_machine.rb
+++ b/lib/rainbows/event_machine.rb
@@ -119,14 +119,15 @@ module Rainbows
           st = io.stat
 
           if st.file?
-            write(response_header(status, headers)) if headers
-            io.close
-            @body = stream = stream_file_data(body.to_path)
-            stream.callback do
+            cb = lambda do
               body.close if body.respond_to?(:close)
               quit unless alive
             end
-            return
+            write(response_header(status, headers)) if headers
+            io.close
+            @body = stream = stream_file_data(body.to_path)
+            stream.errback(&cb)
+            return stream.callback(&cb)
           elsif st.socket? || st.pipe?
             chunk = stream_response_headers(status, headers) if headers
             m = chunk ? ResponseChunkPipe : ResponsePipe