In this post, we will look into HTTP and HTTP methods in detail.
What is HTTP?
HTTP definition based on Mozilla Documentation
Hypertext Transfer Protocol (HTTP) is a protocol which allows the fetching of resources, such as HTML documents. It is the foundation of any data exchange on the Web and a client-server protocol, which means requests are initiated by the recipient, usually the Web browser. A complete document is reconstructed from the different sub-documents fetched, for instance text, layout description, images, videos, scripts, and more.
In simple terms, Hypertext Transfer Protocol (HTTP) is a protocol which facilitates data transfer between client and server. It is mainly designed to enable communication between server and client.
Example: Browser is an HTTP Client which request web pages to the server and server will return the web pages.
- HTTP is simple.
- HTTP is extensible.
- HTTP is stateless but not session less.
Features controlled by HTTP:
Following Features can be controlled using HTTP Protocol.
Below are the steps involved in basic HTTP workflow.
- Open a TCP connection.
- Send an HTTP Request message.
- Read the Response Message sent by the server.
HTTP Messages Format
Request Message sent to the server:
Response Message sent to the server:
The GET method is generally used and it is used to only retrieve the data. Browser request all the web pages and other resources using HTTP GET method.
The HEAD method asks for a response identical to that of a GET request, but without the response body.
The POST method is used to submit an entity to the specified resource, often causing a change in state or side effects on the server.
The PUT method replaces all current representations of the target resource with the request payload.
The DELETE method deletes the specified resource.
The CONNECT method establishes a tunnel to the server identified by the target resource.
The OPTIONS method is used to describe the communication options for the target resource.
The TRACE method performs a message loop-back test along the path to the target resource.
The PATCH method is used to apply partial modifications to a resource.