What is HTTP?

Melih Firat
4 min readSep 23, 2024

--

Hypertext Transfer Protocol is a protocol in the application layer of the OSI reference model and is used for data transfer between networks.

It usually has a flow where the Client machine makes a request to the Server machine and receives a response at the end of this request. When browsing websites, the person browsing the site is called the Client and the structure that provides the content of the site is called the Server.

The texts, videos, images, CSS and JS codes on a website are the data presented to us by the Server as a result of HTTP requests.

From developer.mozilla.org

Overview of HTTP Request and Response

HTTP sent from the Client to the Server is called HTTP Request. The response from the Server to the Client is called HTTP Response.

HTTP Request

The HTTP request has 3 pieces, Start Line, Headers and Body.

The Start Line carries the Method, the Target, and the HTTP version. The Headers provide the Server with helper information that it can use in our request, such as Authorization type, browser version, etc. In the Body, the main information of the request you will make according to the type of request is transmitted. HTTP Body is empty for HTTP GET request. Theoretically, you can write data in the Body of the HTTP GET Request and send it to the server, but usually the Server ignores or rejects the GET request body. This is because GET is used to request data from the server, while other request types are used to send data to the server.

HTTP Request Methods

  • GET: A request method that requests only the resource itself, without requesting changes to anything on the server.
  • POST: A method of request to create a new resource by sending data to the server.
  • PUT: This is a method of request for a complete renewal of an existing data on the server.
  • DELETE: It is a request method to delete a specific data on the server.
  • PATCH: It is a method of request to update a certain part of an existing data on the server. The difference from PUT is that specific fields are updated, not the entire data.

Request Methods below are rarer, but it’s always good to know more.

  • HEAD: Method that excludes response body and requests only header.
  • CONNECT: Let’s say it is to create an HTTP Tunnel for now. Maybe I will explain further in another article.
  • TRACE: Performs a message loop-back test along the path to the target resource.
  • OPTIONS: Requests allowed methods and specific information.

HTTP Response

The HTTP response also has 3 pieces, Start Line, Headers and Body.

This time the Start Line part holds the HTTP version, Response status code and status text. Headers holds helper information such as the type of data or resource returned. The Body also holds the data or resource.

Instead of Request Methods, which we see differently in Response, we have Response Status instead of Request Method. Finally, let’s look at Response statuses and end our topic.

HTTP Response Status Codes

Status codes start with;
100–199 are informative.
200–299 indicates that the request was successful.
300–399 are indicates a redirect.
400–499 indicates that the user made an incorrect request.
500–599 indicates that the request failed due to a problem with the server.

Extra Information

If you open the console with F12 in your browser and go to the Network tab, you will see a list of HTTP Responses. As an example, I will show you the Response of the CSS Request from medium.com, and we will come to the end of the article.

Here you will see that different types of resources such as CSS, JS, Media are provided from the Server via HTTP.

Here the header of the response is like this

And the body is like this

Thanks for reading, I hope this article has made your light bulb shine.

My LinkedIn: firatmelih

My GitHub: firatmelih

--

--

Melih Firat

Turkish Computer Engineer, trying to explain every step on Backend Roadmap GitHub: firatmelih LinkedIn: firatmelih