skipnothing/HTTP & Networking

Methods & Semantics

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.

  • ▸One cell of the grid stays empty forever: anything read-only can be repeated for free, so nothing lands there.
  • ▸A dropped reply is not a dropped request: resend a POST and you charge twice; resend a PUT, nothing moves.
  • ▸In curl, GET to DELETE flips one token on the wire, yet caches and routers treat the two differently.
BUILDS ON
01

The Safe × Idempotent Grid

Eight common method names, two yes/no questions, and the grid fills in, except one square stays empty. The first question: is the method safe, its defined semantics read-only, a promise to leave the resource alone? The second: is it idempotent, so sending it twice leaves the server exactly where sending it once would?

GET, HEAD, OPTIONS, and TRACE all answer yes to both. POST and PATCH answer no to both: POST hands the resource your data to process however it likes, so two sends can mean two rows, and a PATCH like increment-by-one changes the resource again on every repeat. PUT and DELETE sit in between, a repeat changes nothing past the first send, so they are idempotent, yet that first send is a write, so they are not safe. That second answer is the one a client library acts on when a reply goes missing and it must decide whether to send again: urllib3's default retry list is exactly the six idempotent methods.

The empty square is the whole point. No method is safe but not idempotent, because a request that changes nothing can be repeated forever and still change nothing: read-only forces repeat-safe. The four-corner grid you expected has only three live corners, and every method the protocol defines falls into one of them.

PICK THE RETRY SET, DROP EVERY REPLY

Keep going, sign up to unlock the rest

4 more parts in this topic, plus 23+ more topics in HTTP & Networking.

Sign up, it's freeSee the full HTTP & Networking