rainbows.git  about / heads / tags
Unicorn for sleepy apps and slow clients
blob bbb9ec54124c361f7f8f029ea1b4acd46200ede0 501 bytes (raw)
$ git show HEAD:lib/rainbows/reverse_proxy/synchronous.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
 
# -*- encoding: binary -*-
# :enddoc:
module Rainbows::ReverseProxy::Synchronous
  UpstreamSocket = Rainbows::ReverseProxy::UpstreamSocket

  def each_block(input)
    buf = ""
    while input.read(16384, buf)
      yield buf
    end
  end

  def call(env)
    input = prepare_input!(env)
    req = build_headers(env, input)
    sock = UpstreamSocket.new(pick_upstream(env))
    sock.write(req)
    each_block(input) { |buf| sock.kgio_write(buf) } if input
    Kcar::Response.new(sock).rack
  end
end

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