๐ฎ HTTP: cheat sheet
๐จ The analogyOrdering from a shop by letter: you send a form, and the shop replies with a numbered slip.
๐ The regular explanationThe request-and-response language of the web. A client sends a method, a path and headers; the server answers with a status code, headers and a body.
- You'd like the shop's menu. On the order form you write what to do, GET, and which thing, /menu.
- Off goes the letter.
- The shop reads the form and fetches the menu from the back.
- Back comes a reply slip. The number 200 on top means "all good", and the menu is tucked inside.
- That's the whole game. One letter, one reply. The pictures on the menu need letters of their own.
- The old address replies 301, "we moved, try over there". Numbers starting with 3 point you somewhere else.
- You try the new shop and get 200. Numbers starting with 2 mean success.
- You ask for dragons. 404, "we've never sold those". A 4 means the question itself was the problem.
- A shelf collapses in the shop. 500. A 5 means the shop has a problem, so asking again later might work.
- All fixed, but you sent a hundred letters in a minute. 429, "slow down please".
- The shop sends the catalogue with a note, "still good for an hour", and a little version sticker, v7.
- Ten minutes later you want it again. It's in your scrapbook and still fresh, so no letter at all.
- Two hours later the "good until" time has passed. You write, "I have v7. Has it changed?"
- The shop replies with a tiny slip, 304, "nothing new, keep yours". No catalogue needs posting again.
- In the old way, a delivery van carries one letter at a time, and waits for the reply before taking the next.
- To go faster, you hire six vans. That's a lot of vans to start up.
- The newer way uses one van, cuts every letter into small pieces, labels each piece and mixes them all in.
- Replies come back as soon as each is ready, in any order, and get put back together at your end.
๐งฉ Key questions
- What does the shop always send back for every letter?
- A reply slip with a number on top. One letter, one reply, every time.
- The reply slip's number starts with 4. What does it mean?
- You asked for something wrong. 2 is all good, 3 look elsewhere, 4 you asked wrong, 5 the shop went wrong.
- Your copy's hour is up. What do you ask the shop?
- "I have version 7, has it changed?", and get a tiny slip if not. Until the hour is up you don't write at all; after that, a tiny check saves the whole catalogue.