aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/integration.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_controller/integration.rb')
-rw-r--r--actionpack/lib/action_controller/integration.rb41
1 files changed, 28 insertions, 13 deletions
diff --git a/actionpack/lib/action_controller/integration.rb b/actionpack/lib/action_controller/integration.rb
index 75e6796dc9..25fb1b93af 100644
--- a/actionpack/lib/action_controller/integration.rb
+++ b/actionpack/lib/action_controller/integration.rb
@@ -121,23 +121,38 @@ module ActionController
status
end
- # Performs a GET request, following any subsequent redirect. Note that
- # the redirects are followed until the response is not a redirect--this
- # means you may run into an infinite loop if your redirect loops back to
- # itself. Headers are treated in the same way as #get.
- def get_via_redirect(path, args={}, headers = {})
- get path, args, headers
+ # Performs a request using the specified method, following any subsequent
+ # redirect. Note that the redirects are followed until the response is
+ # not a redirect--this means you may run into an infinite loop if your
+ # redirect loops back to itself.
+ def request_via_redirect(http_method, path, parameters = nil, headers = nil)
+ send(http_method, path, parameters, headers)
follow_redirect! while redirect?
status
end
- # Performs a POST request, following any subsequent redirect. This is
- # vulnerable to infinite loops, the same as #get_via_redirect. Headers are
- # treated in the same way as #get.
- def post_via_redirect(path, args={}, headers = {})
- post path, args, headers
- follow_redirect! while redirect?
- status
+ # Performs a GET request, following any subsequent redirect.
+ # See #request_via_redirect() for more information.
+ def get_via_redirect(path, parameters = nil, headers = nil)
+ request_via_redirect(:get, path, parameters, headers)
+ end
+
+ # Performs a POST request, following any subsequent redirect.
+ # See #request_via_redirect() for more information.
+ def post_via_redirect(path, parameters = nil, headers = nil)
+ request_via_redirect(:post, path, parameters, headers)
+ end
+
+ # Performs a PUT request, following any subsequent redirect.
+ # See #request_via_redirect() for more information.
+ def put_via_redirect(path, parameters = nil, headers = nil)
+ request_via_redirect(:put, path, parameters, headers)
+ end
+
+ # Performs a DELETE request, following any subsequent redirect.
+ # See #request_via_redirect() for more information.
+ def delete_via_redirect(path, parameters = nil, headers = nil)
+ request_via_redirect(:delete, path, parameters, headers)
end
# Returns +true+ if the last response was a redirect.