Every interaction with a web application is, at its core, an exchange of structured text between a client and a server. Understanding the structure of HTTP requests makes everything else — debugging, API testing, and security testing — far more sensible.
Anatomy of a request
An HTTP request has three parts:
POST /api/login HTTP/1.1
Host: example.com
Content-Type: application/json
Content-Length: 45
{"username":"fawwaz","password":"secret"}
- Request line — the method (
POST), path (/api/login), and protocol version. - Headers — metadata: host, content type, cookies, and much more.
- Body — optional data, for example the JSON of a login form.
The server’s response has a similar shape: status line, headers, then body.
Methods and their semantics
| Method | Purpose | Safe to repeat? |
|---|---|---|
| GET | Retrieve data | Yes |
| POST | Create / submit data | Not always |
| PUT | Replace a resource | Yes |
| DELETE | Remove a resource | Yes (idempotent) |
| PATCH | Modify part of a resource | Not always |
The distinction between safe and idempotent matters: GET must not have side effects. If a sensitive action (say, deleting an account) can be triggered by GET, crawlers and link prefetchers can trigger it accidentally — and CSRF vulnerabilities become far easier to exploit.
Headers that matter for security
Cookie— session identity. Stealing the cookie means stealing the session.Authorization— API credentials (usually a bearer token).RefererandOrigin— used by servers to reduce CSRF risk.Content-Type— determines how the body is parsed.
Status codes: a quick map
2xxsuccess —200 OK,201 Created,204 No Content.3xxredirection —301permanent,302temporary,304cached.4xxclient errors —400,401unauthenticated,403forbidden,404,429too many requests.5xxserver errors.
401vs403: 401 means “who are you?”, 403 means “I know who you are, and you still cannot do this.”
HTTPS and transport
Plain HTTP sends text in the clear: anyone on the network path (public Wi-Fi, ISP, proxy) can read and modify it. HTTPS wraps HTTP inside TLS and provides:
- Confidentiality — content cannot be read by others.
- Integrity — modifications are detected.
- Server authentication — the certificate proves you are talking to the right server.
Looking at your own requests
The fastest way to learn is to watch real traffic from your own applications, for example with curl -v or the Network tab in your browser’s DevTools. The verbose flag shows the whole process: DNS lookup, TLS handshake, request line, headers, and the response.
Once reading HTTP requests feels comfortable, DNS is the natural next topic — every URL has to be translated into an IP address before any of this happens.
