HTTP is the protocol the web runs on. Every time you load a page, call an API, or submit a form, you're making HTTP requests. Understanding what's actually in them makes building and debugging web things significantly easier.
The structure of a request
An HTTP request has three parts: the request line, headers, and optionally a body.
POST /api/users HTTP/1.1
Host: api.example.com
Content-Type: application/json
Authorization: Bearer eyJhbGc...
Content-Length: 42
{"name": "Theo", "email": "me@example.com"}
Methods
The method tells the server what you want to do:
- GET — retrieve something. No body. Safe to repeat.
- POST — create something. Has a body. Not safe to repeat.
- PUT — replace something entirely.
- PATCH — update part of something.
- DELETE — remove something.
Headers
Headers are key-value pairs that provide metadata about the request. The important ones:
Content-Type— what format the body is in.application/jsonfor JSON,multipart/form-datafor file uploads.Authorization— credentials. UsuallyBearer TOKENfor API auth.Accept— what format the client wants the response in.Host— which domain the request is for. Required in HTTP/1.1.
Status codes in responses
Responses come back with a status code that tells you what happened:
- 2xx — success. 200 OK, 201 Created, 204 No Content.
- 3xx — redirect. 301 Moved Permanently, 302 Found.
- 4xx — client error. 400 Bad Request, 401 Unauthorized, 403 Forbidden, 404 Not Found.
- 5xx — server error. 500 Internal Server Error, 502 Bad Gateway, 503 Service Unavailable.
Seeing real requests
Open browser dev tools, go to the Network tab, and reload a page. Every HTTP request the page makes is listed there — click one to see the full headers, body, and response. This is the fastest way to understand what's actually happening between a browser and a server.