class Thin::AsyncResponse
Response whos body is sent asynchronously.
Attributes
callback[R]
closed[R]
headers[R]
status[RW]
Public Class Methods
new(env, status=200, headers={})
click to toggle source
# File lib/message_bus/rack/thin_ext.rb, line 43 def initialize(env, status=200, headers={}) @callback = env['async.callback'] @body = DeferrableBody.new @status = status @headers = headers @headers_sent = false end
Public Instance Methods
done()
click to toggle source
Tell Thin the response is complete and the connection can be closed.
# File lib/message_bus/rack/thin_ext.rb, line 64 def done @closed = true send_headers ::EM.next_tick { @body.succeed } end
send_headers()
click to toggle source
# File lib/message_bus/rack/thin_ext.rb, line 51 def send_headers return if @headers_sent @callback.call [@status, @headers, @body] @headers_sent = true end
write(body)
click to toggle source
# File lib/message_bus/rack/thin_ext.rb, line 57 def write(body) send_headers @body.call(body.respond_to?(:each) ? body : [body]) end
Also aliased as: <<