HTTP protocol made simple

HTTP protocol made simple

Introduction

I want to make a small disclaimer and say that I'm a self-taught developer and I'm not a super network engineer, this article aims to share with others using simple concepts the things that I'm studying. I have tried my best to explain the concepts in the clearest way I could.

  • Why is it important to study HTTP protocol?

  • client-server

  • Stateless protocol

  • Client Action

  • Server status code

  • Headers

  • Conclusion

Why is it important to study HTTP protocol?

HTTP protocol nowadays is super important to know and to have at least a superficial understanding of how it works, because on it is based everything we use today on a browser from the front-end to the back-end, and as developers, I think we should be able to understand the basic concept of it.

Client-Server

HTTP protocol is a client-server model, to better understand this concept I like to imagine that the client-server model is similar to when you order a dish in a restaurant, once the order is made it will go to the kitchen and will be prepared and once it is ready you get the dish you asked for. In this model, the clients are the web browsers that we use every day and that you are currently using to read this article, Servers are web servers that are waiting for requests like YouTube or Amazon.

Stateless protocol

A thing that characterizes the HTTP protocol is that it is stateless so it means that every action that is performed is not related to each other. To understand this you can think about the flip of a coin, every flip does not depend on the previous event and this is what stateless means. Even if HTTP is a stateless protocol nowadays there are things to store the state such as cookies and sessions but for this simple explanation we don't consider them.

Application layer

An important thing about HTTP is that it is an application layer protocol. it means that is at the top of the transport layer protocol; most of the time the transport layer protocol that is based on is TCP(which I will analyze in another blog post), to make things a lot easier for this simple article we will say only that TCP defines how data are transmitted from a different place(and also other things like the format, the packets etc...)

So you can imagine something like this:

Client Action

When the Client makes some requests from the server it always specifies some method, for example, GET, POST, DELETE etc... those are the methods that we use when we create or work with API. For example, the GET method is used to is used to request data from a specified, the POST is used to send data to a server to create/update a resource. You can find a long list online of all the HTTP methods and what they do. The most used I think are GET, POST, UPDATE and DELETE which are the most basic HTTP method and allow you to create the CRUD API.

Server status code

In HTTP protocol are defined some status code that the server return to the client to give feedback on the activities that are performed by the client 200,404,500; what I'm learning with this status code is that you can define an event more accurately you can assign the status code and you can build more clear API.

Headers

The HTTP supports the Headers, and this thing is some data that are added to your request or response. The main purpose of these custom headers is to add some more data when you make the request like the token of an API for authentication or content type and there are a lot more, the headers will be included on both sides so the request side and response side

Conclusion

I want to finish by saying thanks to you to have read all the article, I hope that this has been a good article for you to clarify your idea about what is HTTP protocol, even if I'm not an expert on the topic and there would be a lot more to say about it.
If you liked the article please consider leaving a like and if you want another post about HTTP I will be happy to study and share with you that topic.

Follow and support me:

Special thanks if you subscribe to my channel :)

Did you find this article valuable?

Support Paolo Ferrari by becoming a sponsor. Any amount is appreciated!