Skip to content

Commit

Permalink
More robust relative url root discovery for SCGI compatibility. This …
Browse files Browse the repository at this point in the history
…solves the 'SCGI routes problem' -- you no longer need to prefix all your routes with the name of the SCGI mountpoint. References #3070.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3237 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
jeremy committed Dec 8, 2005
1 parent c1537e8 commit c140e80
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions actionpack/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*

* More robust relative url root discovery for SCGI compatibility. This solves the 'SCGI routes problem' -- you no longer need to prefix all your routes with the name of the SCGI mountpoint. #3070 [Dave Ringoen]

* Fix docs for text_area_tag. #3083. [Christopher Cotton]

* Change form_for and fields_for method signatures to take object name and object as separate arguments rather than as a Hash. [DHH]
Expand Down
3 changes: 2 additions & 1 deletion actionpack/lib/action_controller/request.rb
Expand Up @@ -169,7 +169,8 @@ def path
# 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 ||= server_software == 'apache' ? File.dirname(env["SCRIPT_NAME"].to_s).gsub(/(^\.$|^\/$)/, '') : ''
@@relative_url_root ||= server_software == 'apache' ? env["SCRIPT_NAME"].to_s.sub(/\/dispatch\.(fcgi|rb|cgi)$/, '') : ''

end

# Returns the port number of this request as an integer.
Expand Down
5 changes: 5 additions & 0 deletions actionpack/test/controller/request_test.rb
Expand Up @@ -100,6 +100,11 @@ def test_relative_url_root
@request.relative_url_root = nil
@request.env['SCRIPT_NAME'] = "/collaboration/hieraki/dispatch.cgi"
assert_equal "/collaboration/hieraki", @request.relative_url_root

# apache/scgi case
@request.relative_url_root = nil
@request.env['SCRIPT_NAME'] = "/collaboration/hieraki"
assert_equal "/collaboration/hieraki", @request.relative_url_root
end

def test_request_uri
Expand Down

0 comments on commit c140e80

Please sign in to comment.