HTTP: Hypertext Transfer Protocol. It is the protocol of the internet, the one on which internet runs.
It is an application layer protocol in the Internet protocol suite model for distributed, collaborative, hypermedia information systems. It is the foundation of data communication for the World Wide Web, where hypertext documents include hyperlinks to other resources that the user can easily access.
METHODS
Just as in Real World, we've people performing ACTIONS, be it walking, standing, running etc. In HTTP, we call these 'Actions' as 'METHODS'. There are 8 types of it:
- GET Method
- HEAD Method
- POST Method
- PUT Method
- DELETE Method
- CONNECT Method
- OPTIONS Method
- TRACE Method
Just as we have some purspose for every 'action' in life, there is purpose for every 'method' as well, for the above methods they're acronymed as CRUD:
- Create- if you are working on a website and you want to post something on it, you will be CREATING the post.
- Read- when you want to read something, you will be 'reading' the post.
- Update- if you want to update something on the website, you will be 'updating' the post.
- Delete- if you want to delete something on the website, you will be 'deleting' the post.
- GET- is used to fetch the data from server(that's why we say "get the data from server")
- POST- is used to create the resource or anything on server or website.(suppose when you tweet something, you are actually 'posting' it).
- PUT- is used to update resource in the server or website.
- DELETE- ofcourse, to 'delete' something from website or server.
Now what are the types, that is the question?
Now, as the user or client fetch data regulary, when the data is fetched and it does not affect the content on the server side or the real-time data is not changing, these methods are called SAFE METHODS, include: GET.
And vice-versa when something is fetched it changes the content on the server, they are called UNSAFE METHODS, include: POST, PUT and DELETE.
Then there is also something called IDEMPOTENT.
A HTTP method is idempotent if an identical request can be made once or several times in a row with the same effect while leaving the server in the same state. In other words, an idempotent method should not have any side-effects.
All safe methods are also idempotent, but not all idempotent methods are safe. For example, PUT and DELETE are both idempotent but unsafe.