about summary refs log tree commit homepage
path: root/lib/rainbows
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2012-12-05 03:08:19 +0000
committerEric Wong <normalperson@yhbt.net>2012-12-05 03:10:38 +0000
commitd5c8cc8b51619f0d33f75036c53e3936ad2749b2 (patch)
treec12bc60e1c28a43a0d0fa329a3921e9a7a3d0f65 /lib/rainbows
parentfb671a2d316029169940d00a3f9307c3113541c4 (diff)
downloadrainbows-d5c8cc8b51619f0d33f75036c53e3936ad2749b2.tar.gz
Calling body.close in the normal write_response() code path
is incorrect, and only worked out of sheer luck with
Cramp and async_sinata.

This change allows stream(:keep_open) in Sinatra to work
properly.

Thanks to W. Andrew Loe III for the informative bug report
and reproducible test case.

ref: http://mid.gmane.org/CA+-9oNd1EFqsniPkkPTwu5opTCinbM7-2KHoXov7+y3LE4s4Tg@mail.gmail.com
Diffstat (limited to 'lib/rainbows')
-rw-r--r--lib/rainbows/event_machine/client.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/rainbows/event_machine/client.rb b/lib/rainbows/event_machine/client.rb
index e56931f..fc0dfe3 100644
--- a/lib/rainbows/event_machine/client.rb
+++ b/lib/rainbows/event_machine/client.rb
@@ -64,8 +64,11 @@ class Rainbows::EventMachine::Client < EM::Connection
     @state = :headers if alive
     if body.respond_to?(:errback) && body.respond_to?(:callback)
       @deferred = body
+      write_headers(status, headers, alive)
+      write_body_each(body)
       deferred_errback(body)
       deferred_callback(body, alive)
+      return
     elsif body.respond_to?(:to_path)
       st = File.stat(path = body.to_path)