about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-03-21 01:29:18 -0700
committerEric Wong <normalperson@yhbt.net>2009-03-21 01:46:12 -0700
commit3fc10e70bf3b6aa0d670d2248e801d8745e7c0d2 (patch)
tree2ac70e72b015acad83ec6aa437ed541e1266bdaa /lib
parentff6b50fdf49f47befd22d2ad779f01d69c1f4570 (diff)
downloadunicorn-3fc10e70bf3b6aa0d670d2248e801d8745e7c0d2.tar.gz
Fix the logic in HttpParser up front so we don't have
to mess around with the following convoluted steps:

  1. setting the HTTP_CONTENT_{LENGTH,TYPE} headers
  2. reading the HTTP_CONTENT_{LENGTH,TYPE} headers again
  3. setting the CONTENT_{LENGTH,TYPE} based on the
     HTTP_-prefixed one
  4. deleting the HTTP_CONTENT_{LENGTH,TYPE} headers
     (since Rack doesn't like them)

1, 2, 3 were in the C code, 4 was in Ruby.

Now the logic is:

  1. if CONTENT_{LENGTH,TYPE} headers are seen, don't prefix
     with "HTTP_".

All the branch logic for the new code is done at init time, too
so there's no additional overhead in the HTTP parsing phase.
There's also no additional overhead of hash lookups in the extra
steps.
Diffstat (limited to 'lib')
-rw-r--r--lib/unicorn/http_request.rb2
1 files changed, 0 insertions, 2 deletions
diff --git a/lib/unicorn/http_request.rb b/lib/unicorn/http_request.rb
index ce0e408..f2fe486 100644
--- a/lib/unicorn/http_request.rb
+++ b/lib/unicorn/http_request.rb
@@ -130,8 +130,6 @@ module Unicorn
       raise "No REQUEST PATH" unless @params[Const::REQUEST_PATH]
 
       @params["QUERY_STRING"] ||= ''
-      @params.delete "HTTP_CONTENT_TYPE"
-      @params.delete "HTTP_CONTENT_LENGTH"
       @params.update({ "rack.version" => [0,1],
                       "rack.input" => @body,
                       "rack.errors" => $stderr,