From 17dc99cc5c3a3fc59145724059f36c5c907f6c3f Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 4 May 2009 06:08:36 +0000 Subject: Inline and remove the HttpRequest#reset method These potentially leaves an open file handle around until the next request hits the process, but this makes the common case faster. --- lib/unicorn/http_request.rb | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'lib/unicorn') diff --git a/lib/unicorn/http_request.rb b/lib/unicorn/http_request.rb index e786d79..c356576 100644 --- a/lib/unicorn/http_request.rb +++ b/lib/unicorn/http_request.rb @@ -38,17 +38,6 @@ module Unicorn def initialize(logger) @logger = logger - reset - end - - def reset - input = PARAMS[Const::RACK_INPUT] - if input != NULL_IO - input.close rescue nil - input.close! rescue nil - end - PARAMS.clear - PARSER.reset end # Does the majority of the IO processing. It has been written in @@ -65,6 +54,14 @@ module Unicorn # This does minimal exception trapping and it is up to the caller # to handle any socket errors (e.g. user aborted upload). def read(socket) + # reset the parser + unless NULL_IO == (input = PARAMS[Const::RACK_INPUT]) # unlikely + input.close rescue nil + input.close! rescue nil + end + PARAMS.clear + PARSER.reset + # From http://www.ietf.org/rfc/rfc3875: # "Script authors should be aware that the REMOTE_ADDR and # REMOTE_HOST meta-variables (see sections 4.1.8 and 4.1.9) -- cgit v1.2.3-24-ge0c7