skipnothing/HTTP & Networking

Request Lifecycle

curl -v http://example.com/hello prints almost twenty lines before the page 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.

  • ▸The same four regions carry both directions; only the first line says which is the ask.
  • ▸One missing \r gets a 400 from Apache and Node while Python reads on: smuggling bugs live in that split.
  • ▸curl -v is not magic: its > lines are the request you sent, its < lines the reply's head.
01

One exchange, two messages, one shape

A curl -v run against example.com scrolls past almost twenty lines, but strip curl's own notes and only two messages are left on the wire: the one you sent, the one that came back. Both ride above the connection you already opened, at the HTTP layer, and both are built the same way. A single start-line comes first. Then a run of header field lines, each a Name: value pair. Then one empty line. Then, if there is anything to carry, a message body. Request or response, the skeleton does not change. What tells them apart is only that first line: the request opens with a method, the response opens with a version.

ORDER THE LINES, SEND THE BYTES

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