Introduction
In this blog, we are discussing the importance of HTTP standards.
Importance of HTTP standards
On the world wide web, we have two important entities, client and server. We have one more web service or web API in your project, let's say for instance, we have product controller with the methods insert, update, read, remove. We have one more controller, the order controller, with the methods add, edit, search, delete. When we have individual vocabulary for every controller, it will lead to confusion in the future. For this reason, w3c introduced Http standards or methods.
HTTP Methods
Post: It means the server will create a new resource
Get: Read/search
Put: New/update
Delete: To remove
Patch: Update
Here, we can see that Post and Put both have the capability to create a new resource, so what is the difference between the Post and Put methods?
The differences are...
Idempotent and non-idempotent: If the request URL and the response URL are both the same, than in the sense this is idempotent. If the request URL and response URL are both different, in this sense they are non-idempotent.
Functionality: In the put method we can update, but in the post method we cannot update we can only create.
Resource Identification: In the Post method, the resource identification is created by the server. In the case of the Put method, the client is aware of resource identification
Difference between Put and Patch:
Put is for a full update and patch is for a customized update.
Put:
- HTTP://Customer/1
- {
- name:"madan",
- age:25
- }
On server-side, the customer id 1 will be updated.
Patch:
Used for when you want to update the only name, in the sense you can customize the request payload.
- HTTP://Customer/1
- {
- name:"madan"
- }
Who has to follow the HTTP standards:
Server-side developers are more responsible to follow HTTP standards.
Summary
In this blog we have discussed the importance of HTTP standards and their methods.