Lesson 8 / الدرس 8

The response and its status code / الاستجابة ورمز حالتها

The server answers in the same plain-text shape, and the very first line is a three-digit verdict. Learning to read that number is the single fastest debugging skill on the web.

يجيب الخادم بالشكل النصي العادي نفسه، وأول سطر فيه حكم من ثلاثة أرقام. وتعلّم قراءة ذلك الرقم أسرع مهارة في تتبّع الأعطال على الويب.

A response is a request turned around. First line, headers, blank line, body — the same four parts in the same order. The difference is the first line: instead of saying what it wants, the server says how the asking went.

HTTP/1.1 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 4821

<!DOCTYPE html>
<html lang="en">…
The body after the blank line is the page itself — the HTML you spent a whole course writing. It arrives as text, exactly as you typed it, and the browser builds a page out of it afterwards.

The first digit is the whole story

RangeMeansWho has work to do
1xxHold on, still goingNobody — you rarely see these
2xxIt workedNobody
3xxIt moved, look over thereThe browser, automatically
4xxYour request was wrongYou, the client
5xxThe server brokeWhoever runs the server

Five ranges. Getting this table into your head is most of the benefit: the moment you see a 4 you stop suspecting the server, and the moment you see a 5 you stop rereading your own address.

  • 200 OK — here is what you asked for. By far the most common.
  • 301 and 302 — moved permanently, and moved for now. The browser follows both without asking you.
  • 404 Not Found — the server is fine and understood you; there is simply nothing at that path.
  • 403 Forbidden — it exists, and you may not have it.
  • 500 Internal Server Error — the server tried and something in it failed.

Reading a 4 versus a 5

<p class="code c4">404</p>
<p class="code c5">500</p>
Run it, then change the numbers and the classes. Building the reference card yourself is the point: a 4 sends you back to your own request, a 5 sends you to the server logs. Confusing the two is how people spend an afternoon fixing the wrong thing.

Try it live / جرّب بنفسك

Preview / المعاينة

Check yourself / اختبر نفسك

1. You get a 404. Whose problem is it?

2. A page displays the words "Page not found" but returns 200. Is that fine?

3. Which range means the browser will quietly go somewhere else?

Your task / مهمتك

Build a status-code card you would actually keep: the five ranges, then five specific codes with one line each saying what you would do next. Colour the ranges so a 4 and a 5 are distinguishable at a glance.

ابنِ بطاقة رموز حالة تحتفظ بها فعلًا: النطاقات الخمسة، ثم خمسة رموز محددة مع سطر لكل واحد يقول ما ستفعله بعده. ولوّن النطاقات ليتميّز الـ4 عن الـ5 بنظرة واحدة.

  • All five ranges, each with what it means النطاقات الخمسة كلها، مع معنى كل واحد
  • Five specific codes, each with a next action خمسة رموز محددة، لكل واحد خطوة تالية
  • 4xx and 5xx are visually distinct الـ4xx والـ5xx متمايزان بصريًا
How do you want to submit? / كيف تريد التسليم؟