skipnothing/HTTP & Networking

Status Codes

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.

  • ▸Read a code you have never seen with one digit: an unknown 431 is a 400.
  • ▸A 500 and a refused connection are not one outage: one is an HTTP answer, the other its absence.
  • ▸A 200 can lie: put {"error": ...} in its body and the HTTP layer reports success anyway.
BUILDS ON
01

Read Only the First Digit

A status code is three digits, but only the first one carries the branch. 200, 301, 404, 503: read the leading digit and you already know the shape of the answer. 2xx means the request succeeded. 3xx means look elsewhere. 4xx means the server judged the request itself wrong. 5xx means the server accepted the request and then failed. 1xx is an interim note before the real answer. The last two digits pick a specific member inside a class, but they never move a code out of its lane.

This is not a convention you can bend; the protocol writes it down. A client that meets a code it does not recognize is required to treat it as the x00 of its class. Hand it an unfamiliar 431 and it behaves exactly as if it received a 400; hand it an invented 469 and it still reads a client error, because the 4 is the only digit that decided anything.

So the skill this topic builds is not a lookup table. You will never memorize every code, and you do not need to. Read the first digit, place the code in its class, and you have read it correctly, even for a code that did not exist when your program was written.

SORT BY THE FIRST DIGIT ALONE

Keep going, sign up to unlock the rest

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

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