diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-12-30 08:32:27 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-01-04 16:21:17 -0800 |
commit | ed28feabd79697cb27722036622aeca1fbf0723d (patch) | |
tree | 5ca7a6d91bc3e6df69c54de70157f90440a0c664 /lib/rainbows/event_machine | |
parent | c38bc88363d4c4f5f639540ca86f4dd1225df79e (diff) | |
download | rainbows-ed28feabd79697cb27722036622aeca1fbf0723d.tar.gz |
No need to pass unnecessary variables to response_pipe, just let the client handle it all.
Diffstat (limited to 'lib/rainbows/event_machine')
-rw-r--r-- | lib/rainbows/event_machine/client.rb | 5 | ||||
-rw-r--r-- | lib/rainbows/event_machine/response_pipe.rb | 5 |
2 files changed, 5 insertions, 5 deletions
diff --git a/lib/rainbows/event_machine/client.rb b/lib/rainbows/event_machine/client.rb index 0b46b42..6863be0 100644 --- a/lib/rainbows/event_machine/client.rb +++ b/lib/rainbows/event_machine/client.rb @@ -91,11 +91,11 @@ class Rainbows::EventMachine::Client < EM::Connection end return elsif st.socket? || st.pipe? - @body = io = body_to_io(body) + io = body_to_io(@body = body) chunk = stream_response_headers(status, headers) if headers m = chunk ? Rainbows::EventMachine::ResponseChunkPipe : Rainbows::EventMachine::ResponsePipe - return EM.watch(io, m, self, alive, body).notify_readable = true + return EM.watch(io, m, self).notify_readable = true end # char or block device... WTF? fall through to body.each end @@ -106,6 +106,7 @@ class Rainbows::EventMachine::Client < EM::Connection end def next! + @body.close if @body.respond_to?(:close) @hp.keepalive? ? receive_data(@body = nil) : quit end diff --git a/lib/rainbows/event_machine/response_pipe.rb b/lib/rainbows/event_machine/response_pipe.rb index 3da2417..3b584c7 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, body) - @client, @alive, @body = client, alive, body + def initialize(client) + @client = client end def notify_readable @@ -22,7 +22,6 @@ module Rainbows::EventMachine::ResponsePipe end def unbind - @body.close if @body.respond_to?(:close) @client.next! @io.close unless @io.closed? end |