diff options
Diffstat (limited to 'lib/rainbows/revactor.rb')
-rw-r--r-- | lib/rainbows/revactor.rb | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/lib/rainbows/revactor.rb b/lib/rainbows/revactor.rb index 43dc60d..4cf6f11 100644 --- a/lib/rainbows/revactor.rb +++ b/lib/rainbows/revactor.rb @@ -23,21 +23,28 @@ module Rainbows module Revactor require 'rainbows/revactor/tee_input' + RD_ARGS = { :timeout => 5 } + include Base # once a client is accepted, it is processed in its entirety here # in 3 easy steps: read request, call app, write app response def process_client(client) - buf = client.read or return # this probably does not happen... + rd_args = [ nil ] + remote_addr = if ::Revactor::TCP::Socket === client + rd_args << RD_ARGS + client.remote_addr + else + LOCALHOST + end + buf = client.read(*rd_args) hp = HttpParser.new env = {} alive = true - remote_addr = ::Revactor::TCP::Socket === client ? - client.remote_addr : LOCALHOST begin while ! hp.headers(env, buf) - buf << client.read + buf << client.read(*rd_args) end env[Const::RACK_INPUT] = 0 == hp.content_length ? @@ -57,6 +64,8 @@ module Rainbows HttpResponse.write(client, response, out) end while alive and hp.reset.nil? and env.clear client.close + rescue ::Revactor::TCP::ReadError + client.close rescue => e handle_error(client, e) end |