
Thodoris Kouleris
Software Engineer

Basics of HTTP
HTTP (Hypertext Transfer Protocol) is the set of rules that define how information is exchanged between networked devices, primarily between web servers and client browsers.
It was first developed between 1989 and 1991 by Tim Berners-Lee, the creator of the World Wide Web. As an application-layer protocol, early versions of HTTP (prior to HTTP/3) operated on top of the TCP/IP (Transmission Control Protocol/Internet Protocol) suite. Together, HTTP, TCP, and IP form the core foundation of today’s internet.
The most recent version, HTTP/3, was officially published in 2021. It represents a significant upgrade over its predecessor, HTTP/2, though HTTP/2 remains widely used and continues to be supported by many modern browsers.
Why to use HTTP
HTTP is used to enable communication between web browsers (clients) and web servers, making it the core protocol that powers the web. It is primarily responsible for loading web pages by transferring HTML, CSS, JavaScript, images, and other resources from a server to a browser. Beyond web pages, HTTP is also widely used in APIs and web services, allowing applications to exchange data such as JSON or XML. It supports file transfers and downloads, lets users submit forms like logins or checkout details, and even enables communication between devices such as mobile apps, IoT gadgets, and smart TVs. In short, HTTP provides the rules that allow clients and servers to exchange information reliably across the internet.
How does it work
HTTP works through a request-response model between a client and a server. When you type a URL into your browser or click a link, the browser (the client) sends an HTTP request to the web server hosting the website. This request includes information such as the type of content the client can accept, any cookies for that website, and the specific resource being requested (like an HTML page or image). The server then processes this request and sends back an HTTP response, which contains the requested resource along with a status code indicating whether the request was successful, redirected, or resulted in an error. Common status codes include 200 (OK), 404 (Not Found), and 500 (Internal Server Error).
Once the client receives the response, it processes the data and renders the content, such as displaying a web page in the browser. HTTP also supports additional features like methods—for example, GET to retrieve data, POST to send data, PUT to update data, and DELETE to remove data—allowing more complex interactions between client and server. Each interaction is independent, meaning HTTP is a stateless protocol, so the server does not retain information about previous requests unless mechanisms like cookies, sessions, or tokens are used. This simple yet flexible structure makes HTTP the backbone of communication on the web.
Example of HTTP
When you type http://example.com in your browser, the following happens:
1. HTTP Request (from browser to server):
GET / HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0
Accept: text/html
This request asks the server for the homepage (/) of example.com. It also includes information about the browser (User-Agent) and the types of content it can accept (Accept).
2. HTTP Response (from server to browser):
HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: 1256
<!DOCTYPE html>
<html>
<head>
<title>Example Domain</title>
</head>
<body>
<h1>Welcome to Example.com!</h1>
<p>This is a simple HTTP example.</p>
</body>
</html>
The server responds with a status code (200 OK) indicating the request was successful, the type of content (text/html), and the actual HTML content of the page. The browser then renders this HTML so you see the web page on your screen.
Http Status Codes
HTTP status codes are three-digit numbers returned by a server in response to a client’s request. They indicate whether the request was successful, encountered a problem, or requires further action. Status codes are grouped into five categories:-->
1xx – Informational: The request was received and is being processed. Example: 100 Continue.
2xx – Success: The request was successfully received, understood, and processed. Example: 200 OK, 201 Created.
3xx – Redirection: The client must take additional action to complete the request, often involving a new URL. Example: 301 Moved Permanently, 302 Found.
4xx – Client Error: The request contains an error, such as a malformed syntax or a resource that doesn’t exist. Example: 400 Bad Request, 401 Unauthorized, 404 Not Found.
5xx – Server Error: The server failed to fulfill a valid request due to a problem on its side. Example: 500 Internal Server Error, 503 Service Unavailable.
These codes help both the client and the server understand what happened with a request and decide the next steps, such as retrying, redirecting, or displaying an error message to the user.