1 # -*- encoding: binary -*-
2 module Rainbows::ProcessClient
3 include Rainbows::Response
4 include Rainbows::RackInput
5 include Rainbows::Const
8 @hp = hp = Rainbows::HttpParser.new
9 kgio_read!(16384, buf = hp.buf) or return
13 timed_read(buf2 ||= "") or return
18 env[REMOTE_ADDR] = kgio_addr
19 status, headers, body = APP.call(env.merge!(RACK_DEFAULTS))
22 write(EXPECT_100_RESPONSE)
23 env.delete(HTTP_EXPECT)
24 status, headers, body = APP.call(env)
26 write_response(status, headers, body, alive = @hp.next?)
28 # if we get any error, try to write something back to the client
29 # assuming we haven't closed the socket, but don't get hung up
30 # if the socket is already closed or broken. We'll always ensure
31 # the socket is closed at the end of this function
39 Rainbows::Error.write(self, e)