Permalink
Browse files

ActionDispatch::Request deprecates #request_uri

	* Refactored ActionPatch to use fullpath instead
  • Loading branch information...
Carl Lerche
Carl Lerche committed Mar 3, 2010
1 parent eb49bd6 commit fb14b8c6fddae818b2688ac1e584534390c37f72
@@ -198,7 +198,7 @@ def validate_digest_response(secret_key, request, realm, &password_procedure)
return false unless password
method = request.env['rack.methodoverride.original_method'] || request.env['REQUEST_METHOD']
- uri = credentials[:uri][0,1] == '/' ? request.request_uri : request.url
+ uri = credentials[:uri][0,1] == '/' ? request.fullpath : request.url
[true, false].any? do |password_is_ha1|
expected = expected_response(method, uri, credentials, password, password_is_ha1)
@@ -20,7 +20,7 @@ def process_action(action, *args)
:params => request.filtered_parameters,
:formats => request.formats.map(&:to_sym),
:method => request.method,
- :path => (request.request_uri rescue "unknown")
+ :path => (request.fullpath rescue "unknown")
}
ActiveSupport::Notifications.instrument("action_controller.start_processing", raw_payload.dup)
@@ -3,7 +3,7 @@ module Http
module URL
# Returns the complete URL used for this request.
def url
- protocol + host_with_port + request_uri
+ protocol + host_with_port + fullpath
end
# Returns 'https://' if this is an SSL request and 'http://' otherwise.
@@ -88,15 +88,8 @@ def subdomain(tld_length = 1)
# Returns the request URI, accounting for server idiosyncrasies.
# WEBrick includes the full URL. IIS leaves REQUEST_URI blank.
def request_uri
- uri = "#{@env["SCRIPT_NAME"]}#{@env["PATH_INFO"]}"
- uri << "?#{@env["QUERY_STRING"]}" if @env["QUERY_STRING"].present?
- uri
- end
-
- # Returns the interpreted \path to requested resource after all the installation
- # directory of this application was taken into account.
- def path
- @env['PATH_INFO']
+ ActiveSupport::Deprecation.warn "Using #request_uri is deprecated. Use fullpath instead."
+ fullpath
end
private
@@ -114,7 +114,7 @@ def atom_feed(options = {}, &block)
feed_opts.merge!(options).reject!{|k,v| !k.to_s.match(/^xml/)}
xml.feed(feed_opts) do
- xml.id(options[:id] || "tag:#{request.host},#{options[:schema_date]}:#{request.request_uri.split(".")[0]}")
+ xml.id(options[:id] || "tag:#{request.host},#{options[:schema_date]}:#{request.fullpath.split(".")[0]}")
xml.link(:rel => 'alternate', :type => 'text/html', :href => options[:root_url] || (request.protocol + request.host_with_port))
xml.link(:rel => 'self', :type => 'application/atom+xml', :href => options[:url] || request.url)
@@ -333,7 +333,7 @@ def test_get_with_query_string
with_test_route_set do
get '/get_with_params?foo=bar'
assert_equal '/get_with_params?foo=bar', request.env["REQUEST_URI"]
- assert_equal '/get_with_params?foo=bar', request.request_uri
+ assert_equal '/get_with_params?foo=bar', request.fullpath
assert_equal "foo=bar", request.env["QUERY_STRING"]
assert_equal 'foo=bar', request.query_string
assert_equal 'bar', request.parameters['foo']
@@ -42,7 +42,7 @@ def test_params
end
def test_uri
- render :text => request.request_uri
+ render :text => request.fullpath
end
def test_query_string
@@ -143,34 +143,34 @@ class RequestTest < ActiveSupport::TestCase
assert_equal ":8080", request.port_string
end
- test "request uri" do
+ test "full path" do
request = stub_request 'SCRIPT_NAME' => '', 'PATH_INFO' => '/path/of/some/uri', 'QUERY_STRING' => 'mapped=1'
- assert_equal "/path/of/some/uri?mapped=1", request.request_uri
- assert_equal "/path/of/some/uri", request.path
+ assert_equal "/path/of/some/uri?mapped=1", request.fullpath
+ assert_equal "/path/of/some/uri", request.path_info
request = stub_request 'SCRIPT_NAME' => '', 'PATH_INFO' => '/path/of/some/uri'
- assert_equal "/path/of/some/uri", request.request_uri
- assert_equal "/path/of/some/uri", request.path
+ assert_equal "/path/of/some/uri", request.fullpath
+ assert_equal "/path/of/some/uri", request.path_info
request = stub_request 'SCRIPT_NAME' => '', 'PATH_INFO' => '/'
- assert_equal "/", request.request_uri
- assert_equal "/", request.path
+ assert_equal "/", request.fullpath
+ assert_equal "/", request.path_info
request = stub_request 'SCRIPT_NAME' => '', 'PATH_INFO' => '/', 'QUERY_STRING' => 'm=b'
- assert_equal "/?m=b", request.request_uri
- assert_equal "/", request.path
+ assert_equal "/?m=b", request.fullpath
+ assert_equal "/", request.path_info
request = stub_request 'SCRIPT_NAME' => '/hieraki', 'PATH_INFO' => '/'
- assert_equal "/hieraki/", request.request_uri
- assert_equal "/", request.path
+ assert_equal "/hieraki/", request.fullpath
+ assert_equal "/", request.path_info
request = stub_request 'SCRIPT_NAME' => '/collaboration/hieraki', 'PATH_INFO' => '/books/edit/2'
- assert_equal "/collaboration/hieraki/books/edit/2", request.request_uri
- assert_equal "/books/edit/2", request.path
+ assert_equal "/collaboration/hieraki/books/edit/2", request.fullpath
+ assert_equal "/books/edit/2", request.path_info
request = stub_request 'SCRIPT_NAME' => '/path', 'PATH_INFO' => '/of/some/uri', 'QUERY_STRING' => 'mapped=1'
- assert_equal "/path/of/some/uri?mapped=1", request.request_uri
- assert_equal "/of/some/uri", request.path
+ assert_equal "/path/of/some/uri?mapped=1", request.fullpath
+ assert_equal "/of/some/uri", request.path_info
end

0 comments on commit fb14b8c

Please sign in to comment.