HTTP
HTTP (Hypertext Transfer Protocol) is a request/response protocol: a client sends a request naming a method and a resource, and the server sends back one response with a status code, headers and an optional body. It started as the protocol for web pages and is now the default for APIs, object storage (every S3 GET and PUT is an HTTP call), webhooks and most SaaS data sources your pipelines pull from.
Anatomy of an exchange
| NO. | STEP | FROM | TO | TYPE | INFO |
|---|---|---|---|---|---|
| 1 | 01 | client | server | CONNECT | TCP 3-way handshake + TLS 1.3 (port 443) |
| 2 | 02 | client | server | REQUEST | GET /orders/42 HTTP/1.1 · Host: api.shop.com · Accept: application/json · Authorization: Bearer … |
| 3 | 04 | server | client | RESPONSE | HTTP/1.1 200 OK · Content-Type: application/json · Content-Length: 312 · Cache-Control: private, max-age=0 · ETag: "v7" |
| 4 | 04 | server | client | BODY | {"id":42,"user":"sam","status":"shipped","total":120.0} |
| 5 | 05 | client | server | REQUEST | GET /orders/42 · If-None-Match: "v7" |
| 6 | 05 | server | client | RESPONSE | HTTP/1.1 304 Not Modified (client reuses its cached copy) |
- The client wants order 42 from an API.
- First a connection: TCP, then TLS for HTTPS. Keep-alive lets later requests reuse it.
- The request: a method, a path, a version, then headers. GET has no body.
- The server routes the request to code that builds the answer, often with a database query.
- The response: a status code, headers that describe the body, then the body itself. The ETag is a version tag for this representation.
- Later, the client asks again with If-None-Match. Nothing changed, so the server sends 304 with no body: a cheap cache revalidation.
HTTP is stateless: each request carries everything the server needs (credentials, cookies, parameters). Sessions, logins and shopping carts are built on top with headers and tokens.
Methods
| Method | Meaning | Safe | Idempotent | Body |
|---|---|---|---|---|
| GET | Read a resource | yes | yes | no |
| HEAD | GET without the body | yes | yes | no |
| POST | Create, or run an action | no | no | yes |
| PUT | Replace a resource fully | no | yes | yes |
| PATCH | Change part of a resource | no | not necessarily | yes |
| DELETE | Remove a resource | no | yes | rarely |
Idempotent means repeating the request has the same effect as sending it once. It matters for retries: a pipeline can safely retry a timed-out PUT, but a retried POST /payments might charge twice unless the API supports an idempotency key.
Status codes
| Range | Meaning | Ones to know |
|---|---|---|
| 2xx | Success | 200 OK, 201 Created, 204 No Content |
| 3xx | Look elsewhere | 301/308 moved permanently, 304 Not Modified |
| 4xx | Client’s fault | 400 bad request, 401 not authenticated, 403 not allowed, 404, 409 conflict, 429 too many requests |
| 5xx | Server’s fault | 500, 502 bad gateway, 503 unavailable, 504 gateway timeout |
Retry 429 and 5xx with exponential backoff (respect the Retry-After header). Never blindly retry 4xx: the request itself is wrong.
HTTP/1.1 → HTTP/2 → HTTP/3
The three versions carry the same methods, headers and status codes; what changed is how requests share the network. The main problem each version fixes is head-of-line blocking: one slow or lost piece holding up everything queued behind it.
- A page needs three files, A, B and C, from the same server. Time runs left to right.
- HTTP/1.1: one request at a time per connection. B can't start until A's response is complete. Browsers work around it by opening about 6 connections per host.
- HTTP/2: all three requests share one TCP connection as interleaved streams. No waiting for a whole response.
- One packet carrying B is lost. TCP delivers bytes strictly in order, so frames for A and C that already arrived sit in the buffer until B's packet is resent. Every stream stalls.
- HTTP/3 runs on QUIC over UDP. Streams are still multiplexed on one connection, but QUIC orders bytes per stream, not per connection.
- The same loss now delays only stream B. A and C keep flowing and the page finishes sooner.
| Version | Transport | What changed |
|---|---|---|
| HTTP/1.1 (1997) | TCP | Text format, keep-alive connections, one request at a time per connection |
| HTTP/2 (2015) | TCP + TLS | Binary frames, many requests multiplexed over one connection, header compression. gRPC is built on it. |
| HTTP/3 (2022) | QUIC over UDP | No TCP head-of-line blocking, faster connection setup, survives network changes (Wi-Fi to mobile) |
Since 2022, RFC 9110 defines these shared semantics separately from the wire formats.
Common mistakes
- Pulling an API without pagination or rate-limit handling. Read the
Linkor cursor fields and honor 429s, or the job either misses data or gets banned. - Using GET for actions with side effects. Crawlers, prefetchers and caches assume GET is safe.
- Sending credentials over plain HTTP. Always use HTTPS.
- Treating every non-200 as fatal. 201, 204 and 304 are successes too.
Try it
curl -v https://example.com/ -o /dev/null # the full request and response headers
curl -sI https://www.google.com | head -1 # HTTP/2 200: the version the server picked
curl -sI --http1.1 https://www.google.com | head -1 # force HTTP/1.1
curl -sI --http3 https://www.google.com | head -1 # needs a curl built with HTTP/3 supportLearning Resources
Documentation
- MDN: HTTP: the best reference for methods, headers and status codes
- RFC 9110: HTTP Semantics, RFC 9112: HTTP/1.1, RFC 9114: HTTP/3
Books
- HTTP: The Definitive Guide: Gourley and Totty, old but still the clearest on fundamentals
- High Performance Browser Networking: HTTP/1.1, HTTP/2 and performance, free online
Videos
- HTTP/1 to HTTP/2 to HTTP/3: Hussein Nasser