summary refs log tree commit homepage
path: root/lib/rainbows/process_client.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-11-04 19:52:35 -0700
committerEric Wong <normalperson@yhbt.net>2010-11-04 20:36:17 -0700
commited3a30dcfb5489447dec9c3f73e8bec9dbf7713a (patch)
tree961ad728beb3179d53d33c71770f519dcb52d82e /lib/rainbows/process_client.rb
parent9f185041fb7af4cda21ba2d547fd4d16d9b2e453 (diff)
The long-term goal is to make the Unicorn API more terse when
handling keepalive.
Diffstat (limited to 'lib/rainbows/process_client.rb')
-rw-r--r--lib/rainbows/process_client.rb7
1 files changed, 4 insertions, 3 deletions
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