Sunday, October 19, 2014

HTTP GET vs HTTP POST Requests

The primary difference between HTTP GET and HTTP POST requests is that HTTP GET request asks for data from the specific resource while the HTTP POST request submits data to be processed. For example, in the Guess Number lab the get() method in my code responded to the HTTP GET request from the browser by writing a response that output "Good luck!" with a form asking for the initial guess a submit button. The form then uses an HTTP POST request to provide the guess to be processed by the post() method in my web application.

There are also other differences between HTTP GET and HTTP POST requests. HTTP GET requests include the parameters in the URL, are used for fetching content, have a maximum length dictated by the maximum URL length, are okay to cache, and should not change the server. HTTP POST requests include the parameters in the body of the request, is used for updating data, has no maximum length, is not okay to cache, and can change the server.

No comments:

Post a Comment