From e9504bb6f785a3e38788c9d787eef07d464fdd0c Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Thu, 15 Sep 2005 05:32:16 +0000 Subject: Cache relative_url_root for all webservers, not just Apache #2193 [skae] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2246 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/CHANGELOG | 2 ++ actionpack/lib/action_controller/request.rb | 2 +- actionpack/test/controller/request_test.rb | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) (limited to 'actionpack') diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG index 21d8145ff1..d625d0afaf 100644 --- a/actionpack/CHANGELOG +++ b/actionpack/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* Cache relative_url_root for all webservers, not just Apache #2193 [skae] + * Speed up cookie use by decreasing string copying #2194 [skae] * Fixed access to "Host" header with requests made by crappy old HTTP/1.0 clients #2124 [Marcel Molina] diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb index c3d440d815..00f411e7be 100755 --- a/actionpack/lib/action_controller/request.rb +++ b/actionpack/lib/action_controller/request.rb @@ -166,7 +166,7 @@ module ActionController # Returns the path minus the web server relative installation directory. # This method returns nil unless the web server is apache. def relative_url_root - @@relative_url_root ||= File.dirname(env["SCRIPT_NAME"].to_s).gsub(/(^\.$|^\/$)/, '') if server_software == 'apache' + @@relative_url_root ||= server_software == 'apache' ? File.dirname(env["SCRIPT_NAME"].to_s).gsub(/(^\.$|^\/$)/, '') : '' end # Returns the port number of this request as an integer. diff --git a/actionpack/test/controller/request_test.rb b/actionpack/test/controller/request_test.rb index 5bb5bc3469..2aeff279be 100644 --- a/actionpack/test/controller/request_test.rb +++ b/actionpack/test/controller/request_test.rb @@ -72,8 +72,9 @@ class RequestTest < Test::Unit::TestCase end def test_relative_url_root + @request.env['SCRIPT_NAME'] = "/hieraki/dispatch.cgi" @request.env['SERVER_SOFTWARE'] = 'lighttpd/1.2.3' - assert_nil @request.relative_url_root, "relative_url_root should be disabled on lighttpd" + assert_equal '', @request.relative_url_root, "relative_url_root should be disabled on lighttpd" @request.env['SERVER_SOFTWARE'] = 'apache/1.2.3 some random text' -- cgit v1.2.3