HTTP stands for "Hypertext Transfer Protocol." This protocol is how a browser client talks to a server.
So, in my Pizza example, Hash follows a Hypertext Transfer Protocol to talk to the server, which is the Pizza shop. So basically, if Hash uses a certain language to talk to the Pizza place, then that language would be called HTTP.
In HTTP, there are 9 core commands that we can request from the server; these, in the terminology of HTTP, are called Methods. The rulebook that the Hypertext Transfer Protocol uses is called RFC. RFC stands for Request For Comments. HTTP completely follows this set of rules.
Methods
GET Method
This command retrieves data from a server.
For example when we want to open a website or something like my own website, "TopicGems.com", we search it in the browser, the browser uses a DNS to convert it into an IP address and then the IP address is the way by which we get to the right server which is hosting our website and then the server follows the GET method to provide us with the homepage of my website.
When successfully read, the server responds with a "200 OK".
POST Method
The POST method is used to create new data inside the server.
When we upload a blog on my website, TopicGems.com. The browser-client packs up the data into a POST request and sends it to the server. Through the same DNS IP routing process, the data is sent to the server, and then the server unpacks the data, reads and writes it, and then returns it, and it appears in front of us on the website. The server usually responds to this with 201 Created or 200 OK.
PUT Method
The PUT command is used to make changes to existing content by replacing it.
Suppose you forgot to add the name of the writer of a blog in a blog at TopicGems.com. You make those changes; the browser-client packs those changes and then sends them back to the server through DNS IP routing, and the server reads the changes and responds with 200 OK or 204 Successful No Content.
What 204 No Content means is that the content has already been uploaded, so there is no need for the server to send back any data. This is because the changes made were already added to the database that the writer can see.
BUT BE CAREFUL!! IF YOU ONLY ADD THE NAME OF THE WRITER, THE SERVER WILL DELETE EVERYTHING ELSE, SO MAKE SURE YOU ADD ALL THE INFORMATION WHICH WAS PREVIOUSLY THERE ALONG WITH THE ONE YOU WERE MISSING, AS IT IS A REPLACEMENT COMMAND.
DELETE Method
In the delete method, the server completely removes the content wished to be removed.
Suppose an article at TopicGems.com is too old to be relevant. The client uses the delete button on the website, and then the browser-client will pack a DELETE request with the ID of the content to be deleted and sends it to the server.
The server reads and deletes the requested content and responds with either 200 OK or 204 No Content.
In this case, because there is no data to return to the computer, that's why 204 No Content is used.
PATCH Method
In the PATCH method, we can make specific changes to some existing content without having to replace it.
Suppose we forgot to write the name of the writer at TopicGems.com; we will make the change, and the browser-client will pack it in a PATCH method and send it to the server.
The server will read it and will only make those specific changes without deleting the entire blog like it did in the PUT method.
It responds with a 201 OK or 204 No Content, as we can already see the changes, so there is no need to send it back to the client.
Also, like POST, we have to upload the entire blog with the changes in PATCH; we can fix a small patch of information so this is a very specific command.
HEAD Method
The head method works similarly like the GET method.
It also fetches information from the server but only a specific part of the information.
When we use the GET method we get the entire content we requested. But when we use the HEAD method we only get the metadata headers.
Metadata headers contain hidden information about a file, webpage or an application. They also identify the data, for example the file type, the file size etc.
So rather than getting an entire webpage like we do in the GET method we only get some useful information about the webpage. Like its size, its file type etc.
For example when we use the HEAD method to open a webpage like TopicGems.com, we wont get the page like we do in the GET method, but the browser-client will only fetch the metadata headers of the webpage from the server.
The server responds with 200 OK.
OPTIONS Method
Like we had a POST test conducted by UEFI, we have the OPTIONS method.
In OPTIONS method before running commands like Delete, POST, PUT, PATCH etc the browser-client packs an OPTIONS method packet and sends it to the server through DNS IP routing.
In this command the client simply asks the server if the commands like the one mentioned above are even allowed on this server. Or if the client has enough perms.
The server responds with a 200 OK or 204 No Content.
CONNECT Method
When we are using internet at a place where we have a firewall guarding the network we can not connect to servers easily.
For this we use the Connect method.
In the connect method the browser client packs our request and the connect request to the firewall first it requests it to build a tunnel to the server we want to connect to and then after the connection is established the proxy/firewall server responds with a 200 Connection Established.
This is a mini VPN for just 1 server. But a VPN does the same thing but for your entire device not just 1 server.
TRACE Method
Sometimes you may notice that your POST, PUT or any command related to content changes is working a bit glitchy, you use a HEAD method and notice that there is some weird metadata attached to it.
To check if there is a middleman proxy/firewall making changes to the header you send a Trace request.
The browser-client packs and sends it to the server through DNS IP routing and the server "ECHOES." It back to you, when it does you can easily spot the changes that were made to its metadata i.e the headers and can find out if there is a proxy/firewall making these changes.
