rainbows.git  about / heads / tags
Unicorn for sleepy apps and slow clients
blob 5caf25054a8b72ddd2b63e8f6ca46f29fc9d86ce 511 bytes (raw)
$ git show v0.97.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
24
25
 
# -*- 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
    begin
      data = @io.read_nonblock(16384, BUF)
      @client.write("#{data.size.to_s(16)}\r\n")
      @client.write(data)
      @client.write("\r\n")
    rescue Errno::EINTR
    rescue Errno::EAGAIN
      return
    rescue EOFError
      detach
      return
    end while true
  end
end

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