skipnothing/HTTP & Networking
UNIT 03

HTTP

Request lifecycle, methods, headers, caching, and HTTP/2-3

HTTP is a text protocol that runs over the connection from Unit 2. Method, path, headers, body, status, response. Once you can read `curl -v` output line by line, every API call stops being a black box.

Loading…
TOPICS
#11

Request Lifecycle

Read a `curl -v` transcript line by line: name the request line, header fields, empty-line boundary, and body, tell a status line from a request line by its first token, and sort each line onto the sent or received side of the wire from its `*`, `>`, `<` prefix.

`curl -v https://example.com/hello` prints a dozen lines before the page ever loads, each tagged `*`, `>`, or `<`, and every one is plain text a parser reads top to bottom: no magic, no binary, nothing you cannot spell out yourself.

14 min
#12

Methods & Semantics

Classify each method by its two protocol bits (safe? idempotent?), predict which dropped requests a client auto-retries and which a repeated POST turns into a duplicate, and read the 405 plus Allow header that says the route exists but the verb does not.

`curl -X POST` and `curl -X GET` hit the same URL, and only the letters after `-X` change on the wire. Yet a dropped connection turns one into a free retry and the other into a gamble.

13 min
#13

Headers & Content Negotiation

Weight an Accept wishlist with quality values and predict which representation a server returns, tell a served default apart from a 406 when no listed type is available, and name the Vary header that stops a shared cache serving the wrong variant.

Run `curl` against one report URL twice, change the single line naming which format you will take back, and different bytes come home each time, same address, different document, though the URL never said which.

13 min
#14

Status Codes

Sort any status code into its class from its first digit alone, route a failure by that class (4xx means change the request, 5xx means retry the server), separate a 5xx from a refused connection that returns no code at all, and catch a 200 whose error body means the request actually failed.

`curl` a broken URL and you might get `< HTTP/1.1 503` back, or `curl: (7)` with no `<` line at all. One is the server talking, the other is silence, and they are not the same failure.

12 min
#15

Caching & Revalidation

Drive a stored response from fresh to stale, replay its ETag in a conditional request to pull back a bodyless 304 instead of a full 200, and separate no-cache (still stored, always revalidated) from no-store (never stored).

Run `curl -v https://example.com/logo.png` twice and the first prints a full image behind a screenful of headers. The second can come back before the request ever reaches the server, or with an empty body: same command, very different cost.

14 min
#16

HTTP/2 & HTTP/3

Trace one lost segment across an HTTP/2 connection versus HTTP/3 over QUIC and predict how many streams freeze, explain why multiplexing relocates head-of-line blocking down a layer instead of deleting it, and pick the protocol whose connection survives a client that changes network mid-download.

Run `curl --http3 https://example.com` and the whole page rides one UDP flow; drop a single segment on the older connection and every asset behind it stalls at once. Same request, two transports, two different failure shapes.

14 min
All units