aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-02-27 17:11:05 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-02-27 17:11:05 +0000
commit8cddbf0d37c557688bf833e5437a88d98cfaf046 (patch)
treefc8bc38d597eeaf84d679705fc7c5b31c289ba39 /actionpack
parent6ef19fcd48bef1b70ae1b8a39da1fa9baae088cf (diff)
downloadrails-8cddbf0d37c557688bf833e5437a88d98cfaf046.tar.gz
rails-8cddbf0d37c557688bf833e5437a88d98cfaf046.tar.bz2
rails-8cddbf0d37c557688bf833e5437a88d98cfaf046.zip
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]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@802 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/CHANGELOG4
-rwxr-xr-xactionpack/lib/action_controller/request.rb6
-rw-r--r--actionpack/test/controller/request_test.rb8
3 files changed, 15 insertions, 3 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 2e47b00188..3d8d6f1ceb 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -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)
diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb
index 69c325035b..16117a6079 100755
--- a/actionpack/lib/action_controller/request.rb
+++ b/actionpack/lib/action_controller/request.rb
@@ -77,6 +77,10 @@ module ActionController
(%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
@@ -86,7 +90,7 @@ module ActionController
end
def path
- path = request_uri ? request_uri.split('?').first : ''
+ path = path_info ? path_info : ( request_uri ? request_uri.split('?').first : '' )
end
def port
diff --git a/actionpack/test/controller/request_test.rb b/actionpack/test/controller/request_test.rb
index c31cdd460b..82a1d6bb70 100644
--- a/actionpack/test/controller/request_test.rb
+++ b/actionpack/test/controller/request_test.rb
@@ -54,6 +54,12 @@ class RequestTest < Test::Unit::TestCase
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
@@ -67,4 +73,4 @@ class RequestTest < Test::Unit::TestCase
@request.port = 81
assert_equal "rubyonrails.org:81", @request.host_with_port
end
-end \ No newline at end of file
+end