HTTP⚓︎
Definition⚓︎
HTTP, Hypertext Transfer Protocol, is a protocol. HTTP uses plain text for all information communication between client and server, which is unsafe as it uses the internet.
How HTTP Works⚓︎
HTTP works as a request-response protocol in the client-server computing model. A web browser, for example, may be the client, and an application running on a computer hosting a website may be the server.
Every WWW node has a server progress, which listens for HTTP requests on a specific port (default is port 80). When a client sends an HTTP request to the server, the TCP connection is established. Then the server processes the request and sends back an HTTP response containing the requested resource or an error message. Finally, the TCP connection is closed.
HTTP is state-less - Transaction-Oriented Protocol
HTTP is a stateless protocol, meaning that each request from a client to a server is treated as an independent transaction that is unrelated to any previous request. The server does not retain any information about the client's state between requests.
Cookies and Sessions are commonly used to maintain stateful information across multiple HTTP requests.
HTTP Message Structure⚓︎
There are two types of messages in HTTP: HTTP Request and HTTP Response. Both messages share a similar structure, consisting of the following components:
HTTP Request Message⚓︎
```javascript "Example of HTTP Request" GET /path/resource.html HTTP/1.1 Host: www.example.com User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; Accept-Language: en-US,en;q=0.5 Connection: keep-alive
### **HTTP Response Message**
{width="70%", : .center}
```javascript "Example of HTTP Response"
HTTP/1.1 200 OK
Date: Mon, 27 Jul 2009 12:28:53 GMT
Server: Apache/2.2.14 (Win32)
Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT
Content-Length: 88
HTTP Versions⚓︎
There are several versions of HTTP, with the most commonly used being HTTP/1.1, HTTP/2, and the latest HTTP/3:
- HTTP/1.1: Introduced in 1997, it brought several improvements over the original
HTTP/1.0, including persistent connections, chunked transfer encoding, and additional cache control mechanisms. - HTTP/2: Published in 2015, it introduced significant performance enhancements, such as multiplexing multiple requests over a single connection, header compression, and server push capabilities.
- HTTP/3: The latest version, built on the QUIC (Quick UDP Internet Connections) transport protocol, aims to further improve performance and security by reducing latency and enhancing connection reliability.


