Discussing the article: "Connexus Helper (Part 5): HTTP Methods and Status Codes"

 

Check out the new article: Connexus Helper (Part 5): HTTP Methods and Status Codes.

In this article, we will understand HTTP methods and status codes, two very important pieces of communication between client and server on the web. Understanding what each method does gives you the control to make requests more precisely, informing the server what action you want to perform and making it more efficient.

HTTP methods are the actions we ask the server to perform. When you make an HTTP request, such as accessing a page or sending data, you are "talking" to the server using these verbs. Here are the main ones:

  • GET: This is the good old “give me that”. The browser asks to see something on the server, be it a page, an image, or a file. It just gets the information, without changing anything. Like asking for the restaurant menu, just to see what's on offer.
  • POST: POST is the guy who delivers a package. Here, you are sending data to the server. This is common in forms, like when you register on a website. Think of it as if you were sending a letter: you wait for it to arrive at its destination and do something there, like register you.
  • PUT: When you use PUT, you are basically saying: “change this here for this new version”. It is used to update an existing resource. Like changing the oil in your car – it’s the same car, but now with something new.
  • DELETE: Pretty straightforward, right? It’s “get that out of there.” You’re asking the server to delete something. Goodbye, see you never again.
  • PATCH: PATCH is more delicate. It only changes part of the resource. It’s like fixing a broken part of a toy – you don’t have to change everything, just adjust what’s broken.
  • HEAD: This is GET, but without the body. You only want the header information, not the content. It’s like reading the title of a book without opening the pages.

There are other methods such as CONNECT, OPTIONS, and TRACE, but they are rarely used in the day-to-day work of developers. I will not mention details of each one here, but my goal with the library is that it can support all HTTP methods. If you want to understand more about all HTTP methods, access the complete protocol documentation here. But trust me, the most common requests in the day-to-day work of developers, such as GET, POST, and DELETE, are enough for most problems.

Author: joaopedrodev