A request is a line naming a method and a path, a set of headers, and optionally a body. A response is a status line, a set of headers, and usually a body. That is the whole shape, and it has not changed since the protocol's first versions, even as the transport underneath moved from one connection per request to multiplexed streams to a different transport protocol entirely. Each request is independent: the server does not remember the previous one unless a header, usually a cookie or an authorisation token, carries the memory. Every session, login and shopping cart on the web is built on top of that statelessness by choice, and understanding that choice explains most of the security and caching behaviour a developer meets.
| Status class | Means | Examples worth knowing |
|---|---|---|
| 2xx | Success | 200 OK, 201 Created, 204 No Content |
| 3xx | Go elsewhere | 301 permanent redirect, 302 temporary, 304 not modified since you last asked |
| 4xx | Your request is wrong | 400 malformed, 401 not authenticated, 403 not allowed, 404 not found, 429 too many requests |
| 5xx | The server failed | 500 generic failure, 502 and 504 the thing behind the server failed or timed out |
- GET reads and must not change anything; browsers and caches assume so.
- POST submits something new and may change state; repeating it may create a duplicate.
- PUT replaces a resource at a known address; repeating it is harmless, which is the property the API designs on this site's REST page lean on.
- PATCH changes part of a resource; DELETE removes one.
- Headers carry the rest: content type, caching instructions, authentication, the host being addressed, and the cookie that turns a stateless protocol into a session.
