rainbows.git  about / heads / tags
Unicorn for sleepy apps and slow clients
blob 42483c20b502297c6a83c9ab791756ef93ee7aee 422 bytes (raw)
$ git show HEAD:lib/rainbows/coolio/response_pipe.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
 
# -*- encoding: binary -*-
# :enddoc:
#
# this is class is specific to Coolio for writing large static files
# or proxying IO-derived objects
class Rainbows::Coolio::ResponsePipe < Coolio::IO
  def initialize(io, client, body)
    super(io)
    @client, @body = client, body
  end

  def on_read(data)
    @client.write(data)
  end

  def on_close
    @body.respond_to?(:close) and @body.close
    @client.next!
  end
end

git clone https://yhbt.net/rainbows.git