Created
January 9, 2011 08:53
-
-
Save janx/771546 to your computer and use it in GitHub Desktop.
redirect POST
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# RFC2616 10.3.3 | |
# If the 302 status code is received in response to a request other | |
# than GET or HEAD, the user agent MUST NOT automatically redirect the | |
# request unless it can be confirmed by the user, since this might | |
# change the conditions under which the request was issued. | |
# Note: RFC 1945 and RFC 2068 specify that the client is not allowed | |
# to change the method on the redirected request. However, most | |
# existing user agent implementations treat 302 as if it were a 303 | |
# response, performing a GET on the Location field-value regardless | |
# of the original request method. The status codes 303 and 307 have | |
# been added for servers that wish to make unambiguously clear which | |
# kind of reaction is expected of the client. | |
# Curl will use the original request method when in redirect request (if you use -L) | |
# Browsers will always use GET, if you want to change the behaviro POST-Redirect-GET | |
# to POST-Redirect-POST, use status code 307. e.g. when browser POST to below action, | |
# it will prompt user there's a new location (/foo) to POST and POST to "/foo" if user | |
# confirmed | |
def your_action | |
response.status = 307 | |
response.location = "/foo" | |
render :nothing => true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment