Skip to content

Commit

Permalink
Added PATH_INFO access from the request that allows urls like the fol…
Browse files Browse the repository at this point in the history
…lowing to be interpreted by rails: http://www.example.com/dispatcher.cgi/controller/action -- that makes it possible to use rails as a CGI under lighttpd and would also allow (for example) Rublog to be ported to rails without breaking existing links to Rublog-powered blogs. #728 [Jamis Buck]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@802 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed Feb 27, 2005
1 parent 6ef19fc commit 8cddbf0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
4 changes: 3 additions & 1 deletion actionpack/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
*SVN*

* Fixed that caching the root would result in .html not index.html
* Added PATH_INFO access from the request that allows urls like the following to be interpreted by rails: http://www.example.com/dispatcher.cgi/controller/action -- that makes it possible to use rails as a CGI under lighttpd and would also allow (for example) Rublog to be ported to rails without breaking existing links to Rublog-powered blogs. #728 [Jamis Buck]

* Fixed that caching the root would result in .html not index.html #731 [alisdair]


*1.5.0* (24th February, 2005)
Expand Down
6 changes: 5 additions & 1 deletion actionpack/lib/action_controller/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ def request_uri
(%r{^\w+\://[^/]+(/.*|$)$} =~ env['REQUEST_URI']) ? $1 : env['REQUEST_URI'] # Remove domain, which webrick puts into the request_uri.
end

def path_info
env['PATH_INFO']
end

def protocol
env["HTTPS"] == "on" ? 'https://' : 'http://'
end
Expand All @@ -86,7 +90,7 @@ def ssl?
end

def path
path = request_uri ? request_uri.split('?').first : ''
path = path_info ? path_info : ( request_uri ? request_uri.split('?').first : '' )
end

def port
Expand Down
8 changes: 7 additions & 1 deletion actionpack/test/controller/request_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ def test_request_uri
assert_equal "/", @request.path
end

def test_path_info
@request.env["PATH_INFO"] = "/path/of/some/uri"
assert_equal "/path/of/some/uri", @request.path_info
assert_equal "/path/of/some/uri", @request.path
end

def test_host_with_port
@request.env['HTTP_HOST'] = "rubyonrails.org:8080"
assert_equal "rubyonrails.org:8080", @request.host_with_port
Expand All @@ -67,4 +73,4 @@ def test_host_with_port
@request.port = 81
assert_equal "rubyonrails.org:81", @request.host_with_port
end
end
end

0 comments on commit 8cddbf0

Please sign in to comment.