ISSUE :
 
Profile photo
Submitted by Kristi Robertson
on July 31st, 2011 at 22:54:34 EST

What is difference between GET and POST request?

i always get confused with this question especially in interviews can some one post simple way to remember difference. and if possible also provide where these are applicable and why .

Thanks


Profile photo
Replied by SBajra
on August 1st, 2011 at 08:15:53 EST
According to RFC2616 (HTTP 1.1),
Reference: http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html
The GET method means retrieve whatever information (in the form of an entity) is identified by the Request-URI.
The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI in the Request-Line. The actual function performed by the POST method is determined by the server and is usually dependent on the Request-URI.

By the name itself, GET method is mainly for data retrieval. GET works based on URL parameters.
For example:
somesite.com/mypage.php?parameter1=value1&parameter2=value2
The amount of data sent by GET is limited by the URL length imposed by various browsers. You can not sent binary data using GET method. Technically you should not make modification on server side using GET method. However, lot of sites do transactions using GET because of its simplicity based on URL. However, there are security risks using GET for data modification. GET method, since it is based on URL, is cached by browsers and its visible easily in the URL address bar. GET does not support binary data. GET method should strictly be used to get data/information and should NOT be used for updates.

Again by the name itself, POST method is mainly for data modification by posting data to the server. POST does not on URL for transmitting data. POST send data/parameters as additional data in the HTTP request.
Sample POST request:
POST /login.php HTTP/1.1
Host: www.somesite.com
User-Agent: Mozilla/4.0
Content-Length: 100
Content-Type: application/x-www-form-urlencoded

parameter1=value1&parameter2=value2

With POST, data posted is part of body of HTTP request. If you use any HTTP listener tool like fiddler then you will be able to see the POST request. However, POST request are much safer than GET as it does not pass data in URL. And hence data is not normally cached. You should always use POST method if you are doing update transactions.
Accepted Answer
Accepted
 Answer

Profile photo
Replied by Kristi Robertson
on August 2nd, 2011 at 23:58:22 EST
thanks alot

Profile photo
Replied by Surya K
on January 2nd, 2012 at 07:30:56 EST
refer this article to remember difference. Provide difference between these two and where to apply.
http://getpostcomparison.blogspot.com