From 3fc10e70bf3b6aa0d670d2248e801d8745e7c0d2 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 21 Mar 2009 01:29:18 -0700 Subject: http11: don't set headers Rack doesn't like 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. --- lib/unicorn/http_request.rb | 2 -- 1 file changed, 2 deletions(-) (limited to 'lib/unicorn') 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, -- cgit v1.2.3-24-ge0c7