Http Methods : From GET to PUT

Http Methods : From GET to PUT

Introduction

In this blog, I wanna go over Http methods, we will understand what are these http methods , its uses and why it is so important to understand these methods.

What exactly is this HTTP??

To understand HTTP methods , we need to first understand what exactly is “HTTP” is .

HTTP stands for HYPERTEXT TRANSFER PROTOCOL, basically combination of 3 words,

HyperText refers to documents that contains link to other documents. For example, Wikipedia provides information on various topics and also includes link to related articles.

Transfer refers to the process of transmitting data from client to server.

Protocal is a set of rules , that we have to follow.

In summary, HTTP is a set of rules that govern how hypertext and other data are transferred over the web.

Why do we need HTTP?

So we understood what is HTTP and the next question that comes to our mind is why do we even need this?

HTTP enables communication between the Client and the Server, whatever communication that we see in the internet today HTTP is one of the reason for it. For example if we want to know which are the top restraunts near me , what we do is make a google search , this google search has to go through this "HTTP” to get the resource.

Think of HTTP as a Swiggy or Zomato delivery partner. Whenever you're craving food, you open the app and place an order. The delivery partner (HTTP) receives your request, goes to the restaurant (the server) where you've ordered from, picks up the food (the requested data), and delivers it back to you (the client).

Without HTTP, this smooth communication between users and servers wouldn't be possible, and the internet as we know it wouldn't function.

What is HTTP methods?

Now that we have understood what HTTP is and also why its essential , its time to understand how communication happens over HTTP.

HTTP methods are the means of communication between the client and the server. There are many HTTP methods each of these defining a specific action the client wants to do to the server.

HTTP methods

  1. HTTP GET

    This method is used to simply retrieve the data from the server. For example if we want to fetch all the restraunt near me , the browser has to send a GET request to the server.

  2. HTTP POST

    This method is used to create a new resource, we send a data to the server using this method and create a new resource using the data sent. For example if we want to order something from a restraunt, the browser has to send a POST request to the server, also sending the required information like what you want to order, whats the quantity, address etc.

  3. HTTP DELETE

    As the name itself says , if we want to remove a resource from the server we need to make a DELETE request. Deleting an account or removing a product from the cart are some of the examples of DELETE request.

  4. HTTP PUT

    This method is used to update an existing item of the resource. For example if user wants to increase or decrease the quantity of food item, PUT request is used in such case where modified data has to be sent to the server, the server will modify the resource accordingly.

STATUS CODES

In addition to the response server also sends a “STATUS CODE”, which is an indicator to the status of the request , like whether the request has been fullfilled , failed or any other reason for success or failure of the request. There are several status codes each of these having a meaning on what happened to the request.

NOTE: There can be different status codes based on response , in the images shown only a type of success status code has been displayed. For example, we can have a 201OK response status code for a post request for a PUT request , if the data we want to update was never present before the request sent.
Similarly for failures we have different status codes. Few status codes has been mentioned below

  • 200 OK → Indicating that the request is successfull.

  • 201 CREATED →Resource was successfully created (POST).

  • 400 Bad Request –> The request was invalid.

  • 401 Unauthorized –> Authentication is required.

  • 404 Not Found –> The requested resource doesn’t exist.

500 Internal Server Error –> Server failed to process the request.

Conclusion

HTTP (Hypertext Transfer Protocol) is the foundation of communication on the web. Every time we browse a website, search for information, or interact with online services, HTTP facilitates the seamless exchange of data between the client (browser) and the server. It defines how requests are made and how responses are delivered, enabling websites and applications to function smoothly.

By using various HTTP methods like GET, POST, PUT, and DELETE, HTTP supports everything from fetching web pages to submitting forms and updating data. Its stateless, flexible, and scalable nature makes it essential for building reliable and interactive web experiences.

In summary, without HTTP, the internet as we know it wouldn't exist—it's the backbone that connects users to the vast world of online information and services.