Status Codes
Lesson 22 of 47 in Coddy's Networking with the Terminal course.
Every response opens with a three digit code, and the first digit tells you who to blame:
- 2xx worked. 200 OK, 201 Created.
- 3xx go somewhere else. 301 moved permanently, 302 found.
- 4xx the request was wrong. 404 not found, 401 unauthorized, 403 forbidden.
- 5xx the server broke. 500 internal error, 503 unavailable.
The 4xx and 5xx split is the useful one. 4xx is your fault, so fix the request: wrong path, missing token, bad data. 5xx is their fault, so retrying may help and changing your request will not.
Remember that a 404 is a perfectly successful request. The connection worked, the server understood, and its answer was "no such thing". curl exits 0.
Challenge
MediumGet two different codes out of the same server.
- Create
index.htmlcontaininghereand serve the folder on port 9112 - Ask for
/index.htmland print its status code - Ask for
/missing.htmland print its status code
Expected output:
200
404Try it yourself
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Networking with the Terminal
5HTTP by Hand
Anatomy of a RequestRequest MethodsStatus CodesResponse HeadersWriting a ResponseRecap: HTTP BasicsPractice on your own: Terminal playground