NetworkingDemonstration content

Understanding HTTP Requests

The anatomy of an HTTP request — methods, headers, bodies, cookies, and status codes that underpin web security testing.

Understanding HTTP Requests
Table of contents

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"}
  1. Request line — the method (POST), path (/api/login), and protocol version.
  2. Headers — metadata: host, content type, cookies, and much more.
  3. 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).
  • Referer and Origin — used by servers to reduce CSRF risk.
  • Content-Type — determines how the body is parsed.

Status codes: a quick map

  • 2xx success — 200 OK, 201 Created, 204 No Content.
  • 3xx redirection — 301 permanent, 302 temporary, 304 cached.
  • 4xx client errors — 400, 401 unauthenticated, 403 forbidden, 404, 429 too many requests.
  • 5xx server errors.

401 vs 403: 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:

  1. Confidentiality — content cannot be read by others.
  2. Integrity — modifications are detected.
  3. 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.

Share
Tags