From ed3a30dcfb5489447dec9c3f73e8bec9dbf7713a Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 4 Nov 2010 19:52:35 -0700 Subject: process_client: fix attempted keepalive on HTTP 0.9 The long-term goal is to make the Unicorn API more terse when handling keepalive. --- lib/rainbows/process_client.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/rainbows/process_client.rb') diff --git a/lib/rainbows/process_client.rb b/lib/rainbows/process_client.rb index 1e2d0d9..d2c9d0e 100644 --- a/lib/rainbows/process_client.rb +++ b/lib/rainbows/process_client.rb @@ -21,6 +21,7 @@ module Rainbows::ProcessClient hp = HttpParser.new client.kgio_read!(16384, buf = hp.buf) remote_addr = client.kgio_addr + alive = false begin # loop until env = hp.parse @@ -43,12 +44,12 @@ module Rainbows::ProcessClient if hp.headers? headers = HH.new(headers) range = make_range!(env, status, headers) and status = range.shift - env = hp.keepalive? && G.alive - headers[CONNECTION] = env ? KEEP_ALIVE : CLOSE + alive = hp.keepalive? && G.alive + headers[CONNECTION] = alive ? KEEP_ALIVE : CLOSE client.write(response_header(status, headers)) end write_body(client, body, range) - end while env && hp.reset.nil? + end while alive && hp.reset.nil? # if we get any error, try to write something back to the client # assuming we haven't closed the socket, but don't get hung up # if the socket is already closed or broken. We'll always ensure -- cgit v1.2.3-24-ge0c7