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 first digit is the whole story
| Range | Means | Who has work to do |
|---|---|---|
| 1xx | Hold on, still going | Nobody — you rarely see these |
| 2xx | It worked | Nobody |
| 3xx | It moved, look over there | The browser, automatically |
| 4xx | Your request was wrong | You, the client |
| 5xx | The server broke | Whoever 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.200 OK— هذا ما طلبت. وهو الأكثر شيوعًا بفارق كبير. -
301and302— moved permanently, and moved for now. The browser follows both without asking you.301و302— نُقل نهائيًا، ونُقل مؤقتًا. ويتبع المتصفح كليهما دون أن يسألك. -
404 Not Found— the server is fine and understood you; there is simply nothing at that path.404 Not Found— الخادم بخير وقد فهمك؛ لكن لا شيء ببساطة على ذلك المسار. -
403 Forbidden— it exists, and you may not have it.403 Forbidden— موجود، ولا يحق لك أخذه. -
500 Internal Server Error— the server tried and something in it failed.500 Internal Server Error— حاول الخادم وفشل شيء بداخله.
200 OK وفي متنه عبارة "عذرًا، غير موجود" — وهذا عيب حقيقي، لأن محركات البحث والمتصفحات وأدوات المراقبة كلها تقرأ الرقم لا الجملة. فحين يبدو شيء معطلًا، تحقق من الرمز قبل أن تصدّق الصفحة.Reading a 4 versus a 5
<p class="code c4">404</p>
<p class="code c5">500</p>
304 Not Modified. ومعناه "عندك هذا أصلًا، فاستخدم نسختك"، ويصل بلا متن إطلاقًا، ولهذا قد تكون إعادة تحميل الصفحة شبه مجانية. والدرس 16 مبني حوله.Try it live / جرّب بنفسك
Check yourself / اختبر نفسك
1. You get a 404. Whose problem is it?
A 4xx means the server understood you perfectly and is telling you the request itself was wrong. The server is working — that is how it managed to answer.
2.
A page displays the words "Page not found" but returns 200. Is that fine?
200. أهذا مقبول؟The visitor reads the sentence; search engines and monitoring read the number. Saying 200 means a missing page gets indexed and never raises an alert.
3. Which range means the browser will quietly go somewhere else?
A 3xx is a redirection. The browser follows it automatically, which is why an address you typed can turn into a different one in the address bar.
Score / النتيجة: 0 / 3
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 متمايزان بصريًا