Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do can you make redirect_to use a different HTTP request?

At the end of one of my controller actions I need to redirect to a page that only accepts put requests. I have been trying to figure out how to get redirect_to to use a put request but to no success.

Is this possible? Or is there another way to accomplish this?

like image 538
vrish88 Avatar asked Mar 21 '09 23:03

vrish88


1 Answers

I don't think you are able to do this, and I suspect that the limitation is part of HTTP itself.

When using redirect_to - the redirection happens as a "302 Moved" header unless otherwise specified in the parameters.

Having a look at the HTTP Spec itself doesn't reveal any way to change the type of request the browser makes via redirect.

HTTP Redirects:

This class of status code indicates that further action needs to be taken by the user agent in order to fulfill the request. The action required MAY be carried out by the user agent without interaction with the user if and only if the method used in the second request is GET or HEAD.

I think you may need to use JavaScript to achieve this functionality, or perhaps rethink the flow of control in your application.

like image 163
Toby Hede Avatar answered Oct 18 '22 08:10

Toby Hede