about summary refs log tree commit homepage
path: root/lib/unicorn.rb
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-08-27 20:29:55 +0000
committerEric Wong <normalperson@yhbt.net>2010-10-04 21:01:27 +0000
commit50c11036dd4898ccfed8b3e0552e88c67b6c63a9 (patch)
tree21cae94fbbfcc52f7c247e4942b51e5e47007d81 /lib/unicorn.rb
parent7a3efe8a03f85c1f2957130986c24ef7931ff44a (diff)
downloadunicorn-50c11036dd4898ccfed8b3e0552e88c67b6c63a9.tar.gz
There's no need for a response class or object since Rack just
uses an array as the response.  So use a procedural style which
allows for easier understanding.

We shall also support keepalive/pipelining in the future, too.
Diffstat (limited to 'lib/unicorn.rb')
-rw-r--r--lib/unicorn.rb11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/unicorn.rb b/lib/unicorn.rb
index 7f91352..2a5f493 100644
--- a/lib/unicorn.rb
+++ b/lib/unicorn.rb
@@ -90,6 +90,7 @@ module Unicorn
                                 :reexec_pid, :orig_app, :init_listeners,
                                 :master_pid, :config, :ready_pipe, :user)
     include ::Unicorn::SocketHelper
+    include ::Unicorn::HttpResponse
 
     # prevents IO objects in here from being GC-ed
     IO_PURGATORY = []
@@ -626,14 +627,16 @@ module Unicorn
     # in 3 easy steps: read request, call app, write app response
     def process_client(client)
       client.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
-      response = app.call(env = REQUEST.read(client))
+      r = app.call(env = REQUEST.read(client))
 
-      if 100 == response[0].to_i
+      if 100 == r[0].to_i
         client.write(Const::EXPECT_100_RESPONSE)
         env.delete(Const::HTTP_EXPECT)
-        response = app.call(env)
+        r = app.call(env)
       end
-      HttpResponse.write(client, response, HttpRequest::PARSER.headers?)
+      # r may be frozen or const, so don't modify it
+      HttpRequest::PARSER.headers? or r = [ r[0], nil, r[2] ]
+      http_response_write(client, r)
     rescue => e
       handle_error(client, e)
     end