Unit 1: Requests and responses · Lesson 2 of 5 · 16 min

Status codes

Three digits tell you how a request went before you read anything else.

mission

You are
The analyst preparing the shop review.
Situation
Your lead wants a quick sense of which pages are public, which need a sign-in and which are blocked.
Goal
Read the status code of the shop's key pages without loading their bodies.
Hand in
A list of paths with their status codes.

The status rack

01

Headers only

-I sends HEAD, which returns the same head as GET without the body.

learner@web-lab
curl -sI http://127.0.0.1:8000/
HTTP/1.1 200 OK
Server: shop/1.4
Date: Wed, 14 Oct 2026 09:00:00 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 322
X-Content-Type-Options: nosniff

you should see 200 OK on the first line.

02

A page that does not exist

learner@web-lab
curl -si http://127.0.0.1:8000/missing | head -n 1
HTTP/1.1 404 Not Found

you should see 404 Not Found.

03

Only the code

-w prints values curl knows after the transfer. %{http_code} is the status, and -o /dev/null throws the body away.

learner@web-lab
curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:8000/health
200

you should see Just 200. Ideal for scripts.

04

Check several paths at once

learner@web-lab
for p in / /shop /login /account /admin /api/orders; do printf '%-12s ' $p; curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:8000$p; done
/            200
/shop        200
/login       200
/account     302
/admin       403
/api/orders  401

you should see A mix of 200, 302, 401 and 403. Each one says something different about the page.

defender tip 401 means sign in first, 403 means the page exists but you may not see it. Both mark something worth protecting, so they go at the top of your notes.

Two kinds of no

401 Unauthorized
HTTP/1.1 401 Unauthorized
{"error": "sign in first"}

Who are you? Sign in and try again.

403 Forbidden
HTTP/1.1 403 Forbidden
Staff network only.

I know the request, and the answer is no.

What a defender takes away

  1. 12xx worked, 3xx go elsewhere, 4xx the client got something wrong, 5xx the server failed.
  2. 2curl -s -o /dev/null -w '%{http_code}' is the fastest way to map an app.
  3. 3401 and 403 point at the parts of an app that matter most.

Questions

0 of 3 solved

Answer each one from what you find on your lab machine.

  1. Show hint

    curl -s -o /dev/null -w '%{http_code}\n' http://127.0.0.1:8000/admin

  2. Show hint

    It sends you somewhere else instead of refusing.