HTTP
HTTP (Hypertext Transfer Protocol) is the application-layer protocol the web runs on. It defines how clients (typically browsers or API consumers) request resources from servers using methods like GET, POST, PUT, and DELETE, and how servers respond with status codes, headers, and an optional body.
How it works
HTTP is a request-response protocol over a reliable transport, traditionally TCP. A request consists of a method, a path, a set of headers, and an optional body. A response consists of a status code (200 OK, 404 Not Found, 500 Server Error), headers, and an optional body. Each exchange is stateless by default; session state is layered on top using cookies or tokens.
Versions
- HTTP/1.1. Text-based, one request per connection or pipelined. Still the lingua franca of the web.
- HTTP/2. Binary framing, multiplexing of streams over a single connection, header compression (HPACK).
- HTTP/3. Runs over QUIC instead of TCP, improving connection setup and behaviour on flaky networks.
Common methods
- GET: retrieve a resource. Safe, idempotent, cacheable.
- POST: submit data, often create a resource. Not safe, not idempotent.
- PUT: replace a resource. Idempotent.
- PATCH: partially update a resource.
- DELETE: remove a resource. Idempotent.
- HEAD, OPTIONS: metadata and CORS preflight.
🔗