How HTTP works: requests, methods, status codes, headers, cookies and HTTP/2 and HTTP/3
In short: HTTP is the request and response protocol of the web. A client sends a method such as GET or POST, a path and headers; the server replies with a status code, headers and usually a body. Cookies keep sessions between requests. HTTP/2 sends many requests over one connection, and HTTP/3 runs over QUIC on UDP for faster connections.
Requests and responses
Every web page, image, API call and software update uses HTTP (and its encrypted form, HTTPS). The client opens a connection to the server, usually on port 443 for HTTPS or 80 for plain HTTP, and sends a request. The server sends one response back.
GET /about HTTP/1.1
Host: www.example.com
User-Agent: Mozilla/5.0
Accept: text/html
HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 5120
Cache-Control: max-age=3600
<!doctype html> ...
The Host header tells the server which website you want, which is how one IP address can host thousands of sites.
Methods
- GET: fetch something. Should never change data.
- POST: send data to be processed, such as a form or login.
- PUT and PATCH: replace or update a resource (common in APIs).
- DELETE: remove a resource.
- HEAD: like GET but only the headers, useful for checks.
- OPTIONS: ask what is allowed, used by browsers for cross-origin checks.
Status codes
| Family | Meaning | Examples |
|---|---|---|
| 1xx | Information | 101 Switching Protocols (WebSockets) |
| 2xx | Success | 200 OK, 201 Created, 204 No Content |
| 3xx | Redirect | 301 Moved Permanently, 302 Found, 304 Not Modified |
| 4xx | Client error | 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 429 Too Many Requests |
| 5xx | Server error | 500 Internal Server Error, 502 Bad Gateway, 503 Service Unavailable, 504 Gateway Timeout |
For network engineers, 502 and 504 are worth remembering: they usually come from a proxy or load balancer that could not reach, or did not hear back from, the server behind it.
Cookies and sessions
HTTP itself has no memory between requests. After you log in, the server sends a Set-Cookie header with a session ID, and the browser sends it back in a Cookie header with every later request. Cookies should be marked Secure (HTTPS only), HttpOnly (not readable by scripts) and SameSite to reduce attacks.
HTTP/2 and HTTP/3
- HTTP/1.1 sends one request at a time per connection, so browsers open several connections.
- HTTP/2 (2015) uses one TCP connection with many parallel streams, binary framing and header compression. Pages load faster with fewer connections.
- HTTP/3 (2022) runs over QUIC, on UDP port 443. Encryption is built in, connections start faster and a lost packet only delays one stream. Most large sites support it. Firewalls that block UDP 443 make browsers fall back to HTTP/2.
Seeing it yourself
Open your browser's developer tools (F12), go to the Network tab and reload a page. Every request appears with its method, status, size and timing, and you can read the headers. From the command line, curl -I https://www.example.com shows just the response headers.
Real-world example: the 502 errors at lunchtime
Users of an internal web app saw "502 Bad Gateway" every day at lunchtime. The web servers were fine. The reverse proxy in front of them had a limit of 100 connections per server, and the lunchtime ordering rush exceeded it, so the proxy refused new ones. Raising the limit and adding a third server stopped the errors.
Practice
Which HTTP header lets many websites share one IP address?
What does a 504 status code usually indicate?
Which transport does HTTP/3 use?
Key takeaways
- HTTP is a request and response protocol with methods, headers and bodies.
- Status codes: 2xx success, 3xx redirect, 4xx client error, 5xx server error.
- Cookies carry session IDs because HTTP has no memory between requests.
- HTTP/2 multiplexes streams over TCP; HTTP/3 uses QUIC over UDP.
Original content written by Mohamed Fayas for FM TecHub. © 2026 FM TecHub. You're welcome to share a link to this page; please don't copy the text elsewhere without permission.