aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-09-15 05:32:16 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-09-15 05:32:16 +0000
commite9504bb6f785a3e38788c9d787eef07d464fdd0c (patch)
tree330e207b484c27459cc78249c4c3860594f74cfb /actionpack
parentb37d7a70f9a6d9a114fb21b525fbf1eb9bfcca38 (diff)
downloadrails-e9504bb6f785a3e38788c9d787eef07d464fdd0c.tar.gz
rails-e9504bb6f785a3e38788c9d787eef07d464fdd0c.tar.bz2
rails-e9504bb6f785a3e38788c9d787eef07d464fdd0c.zip
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
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG2
-rwxr-xr-xactionpack/lib/action_controller/request.rb2
-rw-r--r--actionpack/test/controller/request_test.rb3
3 files changed, 5 insertions, 2 deletions
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'