Free tech learning for everyone, from basics to pro

Network FundamentalsNetworking SecurityBeginner

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.

An HTTP requestRequest lineGET /index.html HTTP/1.1HeadersHost, User-Agent, CookieBlank lineend of headersBodyoptional, for POST and PUT
Figure 1. HTTP is plain text structured into a start line, headers and an optional body.
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

FamilyMeaningExamples
1xxInformation101 Switching Protocols (WebSockets)
2xxSuccess200 OK, 201 Created, 204 No Content
3xxRedirect301 Moved Permanently, 302 Found, 304 Not Modified
4xxClient error400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found, 429 Too Many Requests
5xxServer error500 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?
The Host header.
What does a 504 status code usually indicate?
A gateway or proxy did not get a timely response from the server behind it.
Which transport does HTTP/3 use?
QUIC, over UDP port 443.

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.
Tracks your learning on this device only. See your progress on the learning paths.
Verified author✓ Valid
Issued to
Mohamed Fayas
Role
Founder of FM TecHub
Credentials
CCNABTEC HND Network EngineeringBEng (Hons) Computer Networking & Cloud Security
Issuer
FM TecHub · fmtechub.com

He writes practical, plain-English guides on networking, security and cloud.

More about the author →

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.

Email updates: coming soon

New notes, tools and security news from FM TecHub by email, explained simply. Free. We're not collecting email addresses yet; see our privacy policy.

PortServiceStatus
SMTP/25Email updatesopening soon

Meanwhile, stay connected: