about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2009-08-14 21:03:39 -0700
committerEric Wong <normalperson@yhbt.net>2009-08-15 02:35:38 -0700
commitf3b379f938719ed7cdfdf2eb92491db276e2da07 (patch)
tree25671509d888109e31e1fdd2c87ba407d60844cf /lib
parent91bd32a4aacb4d0ee118c360cba7000e4ede76ee (diff)
downloadunicorn-f3b379f938719ed7cdfdf2eb92491db276e2da07.tar.gz
This makes a noticeable difference on light GET/HEAD requests.
Heck, even the tests run a few seconds faster.
Diffstat (limited to 'lib')
-rw-r--r--lib/unicorn/http_request.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/unicorn/http_request.rb b/lib/unicorn/http_request.rb
index 26eff1f..a0d811c 100644
--- a/lib/unicorn/http_request.rb
+++ b/lib/unicorn/http_request.rb
@@ -1,4 +1,5 @@
 # coding:binary
+require 'stringio'
 require 'unicorn_http'
 
 module Unicorn
@@ -17,6 +18,7 @@ module Unicorn
       "SERVER_SOFTWARE" => "Unicorn #{Const::UNICORN_VERSION}".freeze
     }
 
+    NULL_IO = StringIO.new(Z)
     LOCALHOST = '127.0.0.1'.freeze
 
     # Being explicitly single-threaded, we have certain advantages in
@@ -71,7 +73,8 @@ module Unicorn
     # Handles dealing with the rest of the request
     # returns a # Rack environment if successful
     def handle_body(socket)
-      REQ[Const::RACK_INPUT] = Unicorn::TeeInput.new(socket)
+      REQ[Const::RACK_INPUT] = 0 == PARSER.content_length ?
+                               NULL_IO : Unicorn::TeeInput.new(socket)
       REQ.update(DEFAULTS)
     end