rainbows.git  about / heads / tags
Unicorn for sleepy apps and slow clients
blob be980867f7d7f6e36bcfcb3adb5a13ad32d06da2 483 bytes (raw)
$ git show v3.2.0:lib/rainbows/event_machine/response_chunk_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
21
22
23
 
# -*- encoding: binary -*-
# :enddoc:
module Rainbows::EventMachine::ResponseChunkPipe
  include Rainbows::EventMachine::ResponsePipe

  def unbind
    @client.write("0\r\n\r\n")
    super
  end

  def notify_readable
    case data = Kgio.tryread(@io, 16384, RBUF)
    when String
      @client.write("#{data.size.to_s(16)}\r\n")
      @client.write(data)
      @client.write("\r\n")
    when :wait_readable
      return
    when nil
      return detach
    end while true
  end
end

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