Wednesday, March 9, 2011

HTTP POST & GET Requests

Very short post, Developers, please, for the sake of god, DO NOT use hyperlinks for an action which supposed to change the state of anything on the server, they're to be used only to fetch information. Hyperlinks generate an HTTP GET request and are not appropriate for this situation.
Here’s the issue. Almost since HTTP was invented, it has been recognized that there is a fundamental difference between HTTP GET and HTTP POST requests. Tim Berners-Lee wrote about it back in 1996. Use GET requests to retrieve information from the server, and use POST requests to request a change of state on the server.
For example in Rails development, instead of using link_to helper, we must use button_to, It generates an HTML form that contains just a single button. When the user clicks the button, an HTTP POST request is generated and a POST request is just the ticket when we want to do something like add an item to a cart.
So, Please, Please DO NOT misuse hyperlinks for the wrong action.

No comments:

Post a Comment