From 357c610c63e8d6bc4825061ed06d6492edd176cd Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 13 May 2009 11:38:05 -0700 Subject: privatize constants only used by old_rails/static Unicorn proper no longer needs these constants, so don't bother with them. --- lib/unicorn/app/old_rails/static.rb | 10 ++++++---- lib/unicorn/const.rb | 7 ------- 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'lib') diff --git a/lib/unicorn/app/old_rails/static.rb b/lib/unicorn/app/old_rails/static.rb index 7ec6b6d..17c007c 100644 --- a/lib/unicorn/app/old_rails/static.rb +++ b/lib/unicorn/app/old_rails/static.rb @@ -22,6 +22,8 @@ require 'rack/file' class Unicorn::App::OldRails::Static FILE_METHODS = { 'GET' => true, 'HEAD' => true }.freeze REQUEST_METHOD = 'REQUEST_METHOD'.freeze + REQUEST_URI = 'REQUEST_URI'.freeze + PATH_INFO = 'PATH_INFO'.freeze def initialize(app) @app = app @@ -34,10 +36,10 @@ class Unicorn::App::OldRails::Static FILE_METHODS.include?(env[REQUEST_METHOD]) or return @app.call(env) # first try the path as-is - path_info = env[Unicorn::Const::PATH_INFO].chomp("/") + path_info = env[PATH_INFO].chomp("/") if File.file?("#@root/#{::Rack::Utils.unescape(path_info)}") # File exists as-is so serve it up - env[Unicorn::Const::PATH_INFO] = path_info + env[PATH_INFO] = path_info return @file_server.call(env) end @@ -45,11 +47,11 @@ class Unicorn::App::OldRails::Static # grab the semi-colon REST operator used by old versions of Rails # this is the reason we didn't just copy the new Rails::Rack::Static - env[Unicorn::Const::REQUEST_URI] =~ /^#{Regexp.escape(path_info)}(;[^\?]+)/ + env[REQUEST_URI] =~ /^#{Regexp.escape(path_info)}(;[^\?]+)/ path_info << "#$1#{ActionController::Base.page_cache_extension}" if File.file?("#@root/#{::Rack::Utils.unescape(path_info)}") - env[Unicorn::Const::PATH_INFO] = path_info + env[PATH_INFO] = path_info return @file_server.call(env) end diff --git a/lib/unicorn/const.rb b/lib/unicorn/const.rb index 263ea10..241c52e 100644 --- a/lib/unicorn/const.rb +++ b/lib/unicorn/const.rb @@ -8,13 +8,6 @@ module Unicorn # gave about a 3% to 10% performance improvement over using the strings directly. # Symbols did not really improve things much compared to constants. module Const - # This is the part of the path after the SCRIPT_NAME. - PATH_INFO="PATH_INFO".freeze - - # The original URI requested by the client. - REQUEST_URI='REQUEST_URI'.freeze - REQUEST_PATH='REQUEST_PATH'.freeze - UNICORN_VERSION="0.7.0".freeze DEFAULT_HOST = "0.0.0.0".freeze # default TCP listen host address -- cgit v1.2.3-24-ge0c7