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

A real request, complete. Nothing is compressed or encoded here — this is literally the text that travels. The blank line at the end is part of the message: it marks the end of the header section, and without it the server keeps waiting.

The first line says everything important

  1. The method — GET here — is the verb. It says what kind of thing you are asking for. Lesson 10 is entirely about choosing it.
  2. The path — everything from the / onwards, including the query. Notice what is missing: the host is not in this line.
  3. The version — HTTP/1.1. Newer versions exist and are faster, but they carry the same three ideas in a compressed form.

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.

<pre class="req">
<b>GET</b> /shop/dates <b>HTTP/1.1</b>
Host: example.com
Accept: text/html
</pre>
Run it and you have the request laid out as a page you can label. This is worth doing once by hand: a request stops being magic the moment you have written one out yourself.
PartExampleSet by
MethodGETThe link or form you used
Path/shop/dates?size=1kgThe URL, minus scheme and host
VersionHTTP/1.1The browser and server, agreed
Host headerexample.comThe host part of the URL
Bodyname=Ahmed&city=CairoOnly 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 / جرّب بنفسك

Preview / المعاينة

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

1. Why does a request need a Host header when the path is already there?

2. What does the blank line in a request mark?

3. Which of these is not part of the request line?

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 جملة تفصل ما جاء من العنوان عمّا أضافه المتصفح
How do you want to submit? / كيف تريد التسليم؟