Lesson 7 / الدرس 7
The HTTP request / طلب HTTP
The connection is open and neither side has said anything yet. What the client sends first is not a mystery format — it is a few lines of plain text you could type by hand.
الاتصال مفتوح ولم يقل أي طرف شيئًا بعد. وما يرسله العميل أولًا ليس صيغة غامضة — بل بضعة أسطر من النص العادي تستطيع كتابتها بيدك.
DNS gave you a number and the connection reached the right door. Now the client has to say what it wants, and it says it in HTTP — the hypertext transfer protocol. A protocol is only an agreement about wording: say it this way and the other side will understand.
GET /lesson/web/http-request HTTP/1.1
Host: training.gt4it.com
Accept: text/html
Accept-Language: ar,en
User-Agent: Mozilla/5.0
The first line says everything important
-
The method —
GEThere — is the verb. It says what kind of thing you are asking for. Lesson 10 is entirely about choosing it.الأسلوب (method) — وGETهنا — هو الفعل. فهو يقول أي نوع من الطلب تطلب. والدرس 10 كله عن اختياره. -
The path — everything from the
/onwards, including the query. Notice what is missing: the host is not in this line.المسار — كل شيء من/فصاعدًا، بما فيه الاستعلام. ولاحظ ما ينقصه: المضيف ليس في هذا السطر. -
The version —
HTTP/1.1. Newer versions exist and are faster, but they carry the same three ideas in a compressed form.النسخة —HTTP/1.1. وثمة نسخ أحدث وأسرع، لكنها تحمل الأفكار الثلاث نفسها في صورة مضغوطة.
Host ترويسة، ولهذا هو الترويسة الوحيدة التي ترفض HTTP/1.1 العمل بدونها: فقد بيّن الدرس 5 أن جهازًا واحدًا قد يحمل مئات المواقع، فالمسار وحده لا يقول أي موقع قصدت. واحذف Host يجبك الخادم الصحيح بخطأ لا بتخمين.Headers, then a blank line, then maybe a body
Every request has the same shape. The first line, then any number of headers — one per line, each a name and a value — then one blank line. A GET stops there. A request that is sending something, such as a filled-in form, continues after the blank line with a body. Lesson 9 goes through the headers themselves.
GET هناك. أما الطلب الذي يرسل شيئًا، كنموذج مملوء، فيكمل بعد السطر الفارغ بـمتن. والدرس 9 يمر على الترويسات نفسها.<pre class="req">
<b>GET</b> /shop/dates <b>HTTP/1.1</b>
Host: example.com
Accept: text/html
</pre>
| Part | Example | Set by |
|---|---|---|
| Method | GET | The link or form you used |
| Path | /shop/dates?size=1kg | The URL, minus scheme and host |
| Version | HTTP/1.1 | The browser and server, agreed |
| Host header | example.com | The host part of the URL |
| Body | name=Ahmed&city=Cairo | Only on methods that send data |
Where each piece of a request comes from. Every one of them is decided before the request leaves — there is nothing the server can add to its own question.
Try it live / جرّب بنفسك
Check yourself / اختبر نفسك
1.
Why does a request need a Host header when the path is already there?
Host والمسار موجود أصلًا؟The request line carries only the path. On a shared address — which lesson 5 showed is the normal case — the server needs the host to know which site the path belongs to.
2. What does the blank line in a request mark?
It separates the headers from the body. It is required even when there is no body, because without it the server cannot tell that the headers have finished.
3. Which of these is not part of the request line?
The scheme decided how to connect and never travels inside the message. By the time the request is written, the encrypted connection it asked for already exists.
Score / النتيجة: 0 / 3
Your task / مهمتك
Write out, as a page, the exact request your browser sends for a page you use — method, path, version, and three headers you actually saw. Label each line with what it does. Then add one sentence saying which part came from the URL and which part the browser added on its own.
اكتب في صفحة الطلب الدقيق الذي يرسله متصفحك لصفحة تستخدمها — الأسلوب والمسار والنسخة وثلاث ترويسات رأيتها فعلًا. وسمِّ كل سطر بما يفعله. ثم أضف جملة تقول أي جزء جاء من العنوان وأي جزء أضافه المتصفح من عنده.
- The request line has all three of its parts سطر الطلب فيه أجزاؤه الثلاثة
- At least three real headers, each labelled ثلاث ترويسات حقيقية على الأقل، كل منها مسمّاة
- A sentence separating what came from the URL from what the browser added جملة تفصل ما جاء من العنوان عمّا أضافه المتصفح