What is HTTP?
Hypertext Transfer Protocol is a set of rules which allows us to retrieve data from servers. It is the underlying format that is used to structure request and responses for effective communication between a client and a server. A complete document is constructed by making different calls to server.
So like in communication we have sender and receiver, same is the case here. The former being the client i.e. browser(most of the times) and latter being the server here.
Clients and servers communicate with each other through messages.The messages sent by the client are called requests and the messages sent by the server in reply are called responses.
Formally put through:
HTTP is a client-server protocol: requests are sent by one entity (client) and response by the other entity (server).
HTTP Request Methods
There are many methods for the browser to make request to the server. It depends on the following operations.
CRUD: Create, Read, Update and Delete.
GET
GET is used to fetch data from a server. GET is one of the most popular HTTP request techniques. It does the operation of Read in the browser.
HEAD
The HEAD method requests a reaction that is similar to that of GET request, but it doesnβt have a message-body in the response.
POST
It is used to create a resource. It performs the operation of Create in the browser. It results in some changes in the server. A typical example for it would be uploading a photo on social media.
PUT
It is used to update a resource. It performs the operation of Update in the browser.
The difference between POST and PUT is that PUT requests are idempotent. This means that if you call the same PUT requests multiple times, the results will always be the same. But the same is not true for POST. POST will result in changes in the server every time we do this.
DELETE
It is used to delete a resource.It performs the operation of Delete in the browser. This method is also idempotent.
Note: There are some other methods as well but these are the commonly used ones.
Top comments (0)