HTTP Methods: There
are 9 main methods in HTTP. These methods indicate what action has to be taken
on the resource. These methods make sure that the client gets the expected
result i.e. the resource he/she desires. Generally resources are the server’s
files or any executable running on the server.
According to HTTP/1.0 specs three main methods were
Later in HTTP/1.1 specs 5 more methods were defined:
RFC 5789 added the PATCH method
GET: This method is used to retrieve the
aforementioned resource. It is the most popularly used method to retrieve
information. Response of a GET request can be cached.
A conditional GET can also be used by adding certain constraints like If-Match, If-None-Match, or If-Range header field, If-Modified-Since, If-Unmodified-Since. A conditional GET works only if certain constraints in header field are fulfilled. Over network usage can be avoided by using partial GET, which specifies Range header field in the request itself.
HEAD: This method is quite synonymous to GET
method but the only striking difference between the two is that the HEAD method
returns an empty Message Body in response.
Response to HEAD may be cached if it varies
from previous cached versions.
This method is popularly used to fetch
meta-information from headers.
POST: This method is used to send some data to
server this data is encapsulated in request body, generally to store it. For e.g.:
web forms. POST method has no restrictions to amount of data that can be sent
as a part of query as it encapsulates this data into request message body. Whereas
in GET method there’s restriction over amount of data in query string.
Also this method is preferable while
transferring confidential information like passwords as URL encoded query won’t
appear in browser’s address box.
It is an idempotent method.
OPTIONS: This method is used to retrieve information
about the HTTP service options for target resource available at the sever end
or intervening intermediary’s end. We can also determine the server’s capabilities
using this method with ‘*’.
Responses to this method are not cacheable.