COE 558Lecture 03المحاضرة 03Part 02الجزء 02
HTTP methods and message anatomyطرق HTTP وتشريح الرسائل
How the four CRUD operations map onto GET, POST, PUT and DELETE, and how to read every field of an HTTP request and response using the index.html example.كيف تُربط عمليات CRUD الأربع بالطرق GET وPOST وPUT وDELETE، وكيف تقرأ كل حقل في طلب HTTP واستجابته باستخدام مثال index.html.
- Conceptsالمفاهيم
- 3
- Slidesالشرائح
- 8-12
- Readingمدة القراءة
- 18 min18 دقيقة
Why this part mattersلماذا يهمّ هذا الجزء
Part 01 said a client talks to an endpoint through an API. This part opens the envelope and shows exactly what travels: which verb the client picks, and what the request and the response look like as text on the wire.
ذكر الجزء 01 أن العميل يتواصل مع endpoint عبر API. هذا الجزء يفتح الظرف ويُريك بالضبط ما الذي ينتقل: أي فعل (verb) يختاره العميل، وكيف يبدو الطلب والاستجابة كنصٍّ على السلك.
Everything later in the lecture, designing endpoints for the lamp API and the REST constraints, is written in this vocabulary. On the midterm you should be able to look at a raw message and name each piece without hesitating, and to map Create, Read, Update and Delete to their methods in your sleep.
كل ما يأتي لاحقًا في المحاضرة، من تصميم الـ endpoints لـ API المصباح إلى قيود REST، مكتوب بهذه المفردات. في الامتحان النصفي يجب أن تستطيع النظر إلى رسالة خام وتسمية كل جزء منها دون تردد، وأن تربط Create وRead وUpdate وDelete بطرقها حتى وأنت نائم.
By the end you canفي نهاية هذا الجزء ستستطيع
- Map each CRUD operation to its HTTP method from memory, in both slide orders.اربط كل عملية من عمليات CRUD بطريقة HTTP المقابلة لها من الذاكرة، بترتيبي الشريحتين كليهما.
- Say which methods are safe and which are idempotent, and why POST is neither.حدد أي الطرق آمنة (safe) وأيها متساوية الأثر (idempotent)، ولماذا لا تكون POST أيًّا منهما.
- Label every part of an HTTP request: method, request target, version, header fields, empty line, body.سمِّ كل جزء من طلب HTTP: الطريقة (method)، وهدف الطلب (request target)، والإصدار، وحقول الترويسة (header fields)، والسطر الفارغ، والجسم (body).
- Label every part of an HTTP response, and read a status code by its class.سمِّ كل جزء من استجابة HTTP، واقرأ رمز الحالة (status code) من خلال فئته.
- Compute a Content-Length from a body and explain what the empty line does.احسب قيمة Content-Length من جسم الرسالة، واشرح وظيفة السطر الفارغ.
Think of a smart lamp exposed through an API. You might add a new lamp to the system, ask for its current state, set it to a new state, or retire it. Those four actions are all an application ever does to stored data, and HTTP has one verb for each.
تخيّل مصباحًا ذكيًا متاحًا عبر API. قد تضيف مصباحًا جديدًا إلى النظام، أو تسأل عن حالته الحالية، أو تضبطه على حالة جديدة، أو تُخرجه من الخدمة. هذه الأفعال الأربعة هي كل ما يفعله أي تطبيق بالبيانات المخزنة، ولـ HTTP فعل واحد لكل منها.
The table to memorizeالجدول الذي يجب حفظه
The four actions are the CRUD operations: Create, Read, Update, Delete. Each request names its operation with an HTTP method, the verb at the very start of the message. The lecture maps them like this: POST creates a new Resource, GET returns one, PUT updates or replaces one, and DELETE removes one.
الأفعال الأربعة هي عمليات CRUD: الإنشاء (Create)، والقراءة (Read)، والتحديث (Update)، والحذف (Delete). كل طلب يسمّي عمليته بـ HTTP method، وهو الفعل الموجود في بداية الرسالة تمامًا. وتربطها المحاضرة هكذا: POST ينشئ resource جديدًا، وGET يُرجع موردًا، وPUT يحدّث موردًا أو يستبدله، وDELETE يحذفه.
Slide 8 lists GET first. Slide 9 lists the same four in CRUD order, so POST comes first. The mapping is identical; only the row order changed. If an exam table is shuffled, anchor on the pair people swap: you POST a new item (Create) and GET an existing one (Read). DELETE is Delete, and PUT is the one left, Update.
الشريحة 8 تضع GET أولًا. والشريحة 9 تسرد الطرق الأربع نفسها بترتيب CRUD، فتأتي POST أولًا. الربط متطابق؛ لم يتغير إلا ترتيب الصفوف. إذا جاء جدول في الامتحان مخلوط الترتيب، فاعتمد على الزوج الذي يخلط الناس بينه: ترسل عنصرًا جديدًا بـ POST (إنشاء)، وتجلب عنصرًا موجودًا بـ GET (قراءة). DELETE هي الحذف، وPUT هي المتبقية، أي التحديث.
| Methodالطريقة | CRUDCRUD | Actionالإجراء | Safeآمنة (Safe) | Idempotentمتساوية الأثر (Idempotent) |
|---|---|---|---|---|
| POSTPOST | Createإنشاء (Create) | Create a new resourceإنشاء مورد جديد | Noلا | Noلا |
| GETGET | Readقراءة (Read) | Return a resourceإرجاع مورد | Yesنعم | Yesنعم |
| PUTPUT | Update or Replaceتحديث أو استبدال (Update or Replace) | Replace the resource with the state you sendاستبدال المورد بالحالة التي ترسلها | Noلا | Yesنعم |
| DELETEDELETE | Deleteحذف (Delete) | Remove the resourceإزالة المورد | Noلا | Yesنعم |
| PATCHPATCH | Update (partial)تحديث جزئي (Update, partial) | Change only the fields you send (slide 19)تغيير الحقول التي ترسلها فقط (الشريحة 19) | Noلا | Not guaranteedغير مضمون |
PUT replaces, PATCH editsPUT يستبدل، وPATCH يعدّل
The slides write PUT as "Update / Replace", and the word replace is the precise one. A PUT sends the full new state of the resource at a URL the client already knows, and the server stores exactly that. If you PUT a lamp with only a brightness field, a strict server would forget the lamp's colour. For changing one field there is PATCH, defined in RFC 5789, which sends only a set of changes. PATCH does not appear in the tables on slides 8 and 9, but it appears on slide 19, so meet it now.
تكتب الشرائح PUT على أنها "Update / Replace"، وكلمة الاستبدال (replace) هي الأدق. طلب PUT يرسل الحالة الجديدة الكاملة للمورد إلى URL يعرفه العميل مسبقًا، والخادم يخزّن ذلك بالضبط. إذا أرسلت PUT لمصباح بحقل السطوع (brightness) فقط، فإن الخادم الصارم سينسى لون المصباح. لتغيير حقل واحد توجد PATCH، المعرّفة في RFC 5789، وهي ترسل مجموعة من التغييرات فقط. لا تظهر PATCH في جدولي الشريحتين 8 و9، لكنها تظهر في الشريحة 19، لذا تعرّف عليها الآن.
Beyond the slides: safe and idempotentخارج الشرائح: الآمن (safe) ومتساوي الأثر (idempotent)
A method is safe when it does not ask the server to change anything. GET is safe: reading a lamp's state never turns it on. That is why browsers, caches and crawlers feel free to send GET requests on their own.
تكون الطريقة آمنة (safe) عندما لا تطلب من الخادم تغيير أي شيء. GET آمنة: قراءة حالة المصباح لا تشغّله أبدًا. ولهذا تشعر المتصفحات والـ caches وبرامج الزحف (crawlers) بحرية إرسال طلبات GET من تلقاء نفسها.
A method is Idempotent method when sending the same request twice leaves the server in the same state as sending it once. Picture a flaky mobile connection: the app sends a request, the reply is lost, and the app retries. Whether the retry is harmless depends on the method.
تكون الطريقة idempotent (متساوية الأثر) عندما يترك إرسال الطلب نفسه مرتين الخادمَ في الحالة نفسها التي يتركه فيها إرساله مرة واحدة. تخيّل اتصال جوال متقطعًا: يرسل التطبيق طلبًا، فيضيع الرد، فيعيد التطبيق المحاولة. كون إعادة المحاولة غير ضارة يعتمد على الطريقة.
- PUT /lamps/7 with state "on", sent twice: the lamp is "on" after the first and still "on" after the second. Idempotent.PUT /lamps/7 بالحالة "on"، مرسلًا مرتين: المصباح "on" بعد الأول وما زال "on" بعد الثاني. متساوية الأثر (idempotent).
- DELETE /lamps/7 sent twice: the first removes it, the second finds nothing. The response codes differ (often 200 then 404), but the end state, no lamp 7, is the same. Idempotent.DELETE /lamps/7 مرسلًا مرتين: الأول يحذفه، والثاني لا يجد شيئًا. رموز الاستجابة تختلف (غالبًا 200 ثم 404)، لكن الحالة النهائية، أي عدم وجود المصباح 7، هي نفسها. متساوية الأثر (idempotent).
- GET /lamps/7 sent twice: nothing changes at all. Safe, and therefore idempotent.GET /lamps/7 مرسلًا مرتين: لا يتغير أي شيء على الإطلاق. آمنة، وبالتالي متساوية الأثر.
- POST /lamps sent twice: two new lamps with two new IDs. Not idempotent.POST /lamps مرسلًا مرتين: مصباحان جديدان بمعرّفين (IDs) جديدين. ليست متساوية الأثر.
Recall
Without looking: which method goes with each CRUD letter, and which of the four are idempotent?دون أن تنظر: أي طريقة تقابل كل حرف من CRUD، وأي الطرق الأربع متساوية الأثر؟
Quick checkاختبار سريع
A phone app retries a request after a timeout. Which retry can create a duplicate resource on the server?تطبيق على الجوال يعيد إرسال طلب بعد انتهاء المهلة (timeout). أي إعادة محاولة قد تنشئ موردًا مكررًا على الخادم؟
Type http://localhost/index.html into a browser. Before any page appears, the browser, acting as an HTTP client, writes a short text message and sends it to the HTTP server on your own machine.
اكتب http://localhost/index.html في المتصفح. قبل أن تظهر أي صفحة، يكتب المتصفح، بصفته HTTP client، رسالة نصية قصيرة ويرسلها إلى HTTP server على جهازك نفسه.
On the server side the lecture draws the picture of part 01: the Endpoint receives the request, reads the resource from the server's file system, and sends it back. Here the resource is a static file, index.html, so "reading" just means opening the file. Later in the lecture the same pattern will read a lamp's state from a database instead.
على جانب الخادم ترسم المحاضرة صورة الجزء 01: الـ endpoint يستقبل الطلب، ويقرأ المورد من نظام ملفات الخادم، ثم يعيده. هنا المورد ملف ثابت، index.html، لذا فإن "القراءة" تعني ببساطة فتح الملف. لاحقًا في المحاضرة سيقرأ النمط نفسه حالة المصباح من قاعدة بيانات بدلًا من ذلك.
The URL is split across the messageالـ URL يتوزع على أجزاء الرسالة
The URL does not travel as one piece. The host part, localhost, is used to find and connect to the server, and is repeated inside the message as the Host header. The path part, /index.html, goes into the first line. Here is the full request from slide 11:
الـ URL لا ينتقل قطعة واحدة. جزء المضيف (host)، أي localhost، يُستخدم لإيجاد الخادم والاتصال به، ويتكرر داخل الرسالة في ترويسة Host. وجزء المسار (path)، أي /index.html، يذهب إلى السطر الأول. وهذا هو الطلب الكامل من الشريحة 11:
The first line is the Request line. Its grammar in the HTTP/1.1 standard is exact: method, single space, request target, single space, version.
السطر الأول هو request line (سطر الطلب). وقواعده في معيار HTTP/1.1 دقيقة: الطريقة، ثم مسافة واحدة، ثم هدف الطلب، ثم مسافة واحدة، ثم الإصدار.
- Request line: GET /index.html HTTP/1.1.سطر الطلب: GET /index.html HTTP/1.1.
- Zero or more Header fields, one per line, each a name, a colon and a value.صفر أو أكثر من header fields (حقول الترويسة)، حقل في كل سطر، وكل حقل اسم ثم نقطتان رأسيتان (:) ثم قيمة.
- An empty line (just CRLF, the two characters carriage return and line feed).سطر فارغ (مجرد CRLF، أي الحرفين: الرجوع إلى بداية السطر (carriage return) والانتقال إلى سطر جديد (line feed)).
- An optional body. A GET normally has none; a POST or PUT carries the new resource here.جسم اختياري. طلب GET عادةً بلا جسم؛ أما POST أو PUT فيحمل المورد الجديد هنا.
Every part of the slide 11 requestكل جزء من طلب الشريحة 11
- GET
- The method: the operation the client wants, here Read.الطريقة (method): العملية التي يريدها العميل، وهي هنا القراءة (Read).
- /index.html
- The request target: the path that names the resource on the server. The lecturer splits it into the route / and the resource index.html.هدف الطلب (request target): المسار الذي يسمّي المورد على الخادم. ويقسمه المحاضر إلى الـ route وهو / والمورد (resource) وهو index.html.
- HTTP/1.1
- The protocol version the client speaks.إصدار البروتوكول الذي يتحدث به العميل.
- Host: localhost
- Header field naming the server (and port, if not the default). Mandatory in HTTP/1.1.حقل ترويسة يسمّي الخادم (والمنفذ (port) إن لم يكن الافتراضي). وهو إلزامي في HTTP/1.1.
- Accept: text/html
- Header field telling the server which media type the client would like back.حقل ترويسة يخبر الخادم بنوع الوسائط (media type) الذي يود العميل استلامه.
- (empty line)(سطر فارغ)
- A bare CRLF that marks the end of the header fields.CRLF مجرد يعلن نهاية حقول الترويسة.
- (body)(الجسم)
- Absent here. A GET asks for data, so it carries nothing after the empty line.غير موجود هنا. طلب GET يطلب بيانات، لذا لا يحمل شيئًا بعد السطر الفارغ.
Two headers appear on the slide. Host: localhost names the server. It looks redundant, since the client already connected to that machine, but one machine often hosts many websites on one IP address, and Host tells it which one you mean. RFC 9112 makes it mandatory: a client must send Host, and a server must answer 400 Bad Request to an HTTP/1.1 request without it. Accept: text/html says what kind of content the client would like back, here an HTML page. A JSON API client would send Accept: application/json.
تظهر ترويستان في الشريحة. Host: localhost تسمّي الخادم. تبدو زائدة، لأن العميل اتصل بذلك الجهاز أصلًا، لكن جهازًا واحدًا كثيرًا ما يستضيف مواقع عديدة على عنوان IP واحد، وHost تخبره أيها تقصد. ويجعلها RFC 9112 إلزامية: يجب على العميل إرسال Host، ويجب على الخادم أن يرد بـ 400 Bad Request على أي طلب HTTP/1.1 يخلو منها. Accept: text/html تقول نوع المحتوى الذي يود العميل استلامه، وهو هنا صفحة HTML. وعميل API يتعامل بـ JSON سيرسل Accept: application/json.
Route and resource: the lecturer's vocabularyالمسار (route) والمورد (resource): مفردات المحاضر
Slide 11 labels the / as the "HTTP route (root)" and index.html as the "resource". Use those words in this course: the route is where on the server you are going, and the resource is the thing you get. In part 01 a Route was defined as a method plus a path, so GET together with /index.html is one route.
تسمّي الشريحة 11 الرمز / بـ "HTTP route (root)" وindex.html بـ "resource". استخدم هذه الكلمات في هذا المقرر: الـ route هو المكان الذي تذهب إليه على الخادم، والـ resource هو الشيء الذي تحصل عليه. في الجزء 01 عُرِّف الـ route على أنه طريقة زائد مسار، لذا فإن GET مع /index.html يشكّلان route واحدًا.
You can watch a real request yourself. The verbose flag of curl prints what it sends and receives:
يمكنك مشاهدة طلب حقيقي بنفسك. خيار الإسهاب (verbose) في curl يطبع ما يرسله وما يستقبله:
curl -v http://localhost/index.html
> GET /index.html HTTP/1.1
> Host: localhost
> User-Agent: curl/8.5.0
> Accept: */*
>
< HTTP/1.1 200 OK
< Content-Type: text/html
< Content-Length: 500
<
<html> ... </html>Recall
Write the request line for reading index.html from localhost, and name its three parts. Which header is mandatory in HTTP/1.1?اكتب سطر الطلب لقراءة index.html من localhost، وسمِّ أجزاءه الثلاثة. وأي ترويسة إلزامية في HTTP/1.1؟
Quick checkاختبار سريع
Which header field must every HTTP/1.1 request carry, or the server must reject it?أي حقل ترويسة يجب أن يحمله كل طلب HTTP/1.1، وإلا وجب على الخادم رفضه؟
The server found index.html. Its reply has the same shape as the request: a first line, header fields, an empty line, then the body. Only the first line is different.
وجد الخادم index.html. ورده له شكل الطلب نفسه: سطر أول، ثم حقول ترويسة، ثم سطر فارغ، ثم الجسم. السطر الأول وحده هو المختلف.
The status lineسطر الحالة (status line)
A response starts with a Status line: HTTP/1.1 200 OK. It has three parts: the version, the Status code 200, and the status message OK, which the standard calls the reason phrase. Programs act on the number; the phrase is for humans and clients should not rely on it.
تبدأ الاستجابة بـ status line: HTTP/1.1 200 OK. وله ثلاثة أجزاء: الإصدار، وstatus code وهو 200، ورسالة الحالة OK التي يسمّيها المعيار reason phrase. البرامج تتصرف بناءً على الرقم؛ أما العبارة فهي للبشر، ويجب ألا يعتمد عليها العملاء.
Every part of the slide 12 responseكل جزء من استجابة الشريحة 12
- HTTP/1.1
- The protocol version the server answers in.إصدار البروتوكول الذي يجيب به الخادم.
- 200
- The status code: a three-digit outcome for programs to read. 200 means success.رمز الحالة (status code): نتيجة من ثلاثة أرقام تقرؤها البرامج. و200 تعني النجاح.
- OK
- The status message (reason phrase): a human-readable label for the code.رسالة الحالة (reason phrase): تسمية للرمز يقرؤها البشر.
- Content-Type: text/html
- Header field naming the media type of the body, here an HTML page.حقل ترويسة يسمّي نوع وسائط الجسم (media type)، وهو هنا صفحة HTML.
- Content-Length: 500
- Header field giving the size of the body: 500 bytes.حقل ترويسة يعطي حجم الجسم: 500 bytes.
- (empty line)(سطر فارغ)
- A bare CRLF. Everything after it is body.CRLF مجرد. كل ما بعده هو الجسم.
- <html>...</html>
- The message body: the actual content of index.html.جسم الرسالة (message body): المحتوى الفعلي لـ index.html.
The first digit of the code is its class, and the class alone tells you who is responsible. RFC 9110 defines five, and every valid code lies between 100 and 599 (slide 24 returns to this range).
الرقم الأول من الرمز هو فئته، والفئة وحدها تخبرك من المسؤول. يعرّف RFC 9110 خمس فئات، وكل رمز صالح يقع بين 100 و599 (تعود الشريحة 24 إلى هذا النطاق).
| Classالفئة | Meaningالمعنى | In wordsبالكلمات | Examplesأمثلة |
|---|---|---|---|
| 1xx1xx | Informationalمعلوماتية (Informational) | Request received, still processingاستُلم الطلب، وما زالت المعالجة جارية | 100 Continue100 Continue |
| 2xx2xx | Successنجاح (Success) | Request received, understood and acceptedاستُلم الطلب وفُهم وقُبل | 200 OK, 201 Created200 OK, 201 Created |
| 3xx3xx | Redirectionإعادة توجيه (Redirection) | Client must take another step, usually go elsewhereعلى العميل أن يتخذ خطوة أخرى، غالبًا الذهاب إلى مكان آخر | 301 Moved Permanently301 Moved Permanently |
| 4xx4xx | Client errorخطأ من العميل (Client error) | The request is wrong or cannot be fulfilledالطلب خاطئ أو لا يمكن تلبيته | 400 Bad Request, 404 Not Found400 Bad Request, 404 Not Found |
| 5xx5xx | Server errorخطأ من الخادم (Server error) | A valid request, but the server failedطلب صالح، لكن الخادم أخفق | 500 Internal Server Error500 Internal Server Error |
A useful pairing with the CRUD table: a successful GET answers 200 OK, a successful POST usually answers 201 Created, and asking for a lamp that does not exist answers 404 Not Found.
ربط مفيد مع جدول CRUD: طلب GET الناجح يُرد عليه بـ 200 OK، وطلب POST الناجح يُرد عليه عادةً بـ 201 Created، وطلب مصباح غير موجود يُرد عليه بـ 404 Not Found.
The headers describe the bodyالترويسات تصف الجسم
The two response headers on slide 12 tell the client how to read what follows. The Content-Type header, text/html, says the body is an HTML page, so the browser renders it instead of showing raw text. The Content-Length header, 500, says the Message body is exactly 500 bytes long, so the client knows when it has received all of it.
ترويستا الاستجابة في الشريحة 12 تخبران العميل كيف يقرأ ما يليهما. ترويسة Content-Type، وقيمتها text/html، تقول إن الجسم صفحة HTML، فيعرضها المتصفح بدلًا من إظهار نص خام. وترويسة Content-Length، وقيمتها 500، تقول إن الـ message body طوله 500 bytes بالضبط، فيعرف العميل متى استلمه كله.
Worked exampleمثال محلول
Computing Content-Length for a tiny pageحساب Content-Length لصفحة صغيرة جدًا
Write the bodyاكتب الجسم
Suppose the server returns the smallest possible page: <html></html>.لنفترض أن الخادم يُرجع أصغر صفحة ممكنة: <html></html>.Count charactersعُدّ الحروف
<html> is 6 characters and </html> is 7, so the body has 6 + 7 = 13 characters.<html> تتكون من 6 حروف و</html> من 7، لذا يحتوي الجسم على 6 + 7 = 13 حرفًا.Convert to bytesحوّل إلى بايتات
Every character here is ASCII, and an ASCII character takes one byte in UTF-8. So 13 characters = 13 bytes.كل حرف هنا من ASCII، وحرف ASCII يأخذ بايتًا واحدًا في UTF-8. إذن 13 characters = 13 bytes.Resultالنتيجة
Content-Length: 13. Headers and the status line are not counted, only the body.Content-Length: 13. الترويسات وسطر الحالة لا تُحسب، الجسم فقط.
The empty line the slide leaves outالسطر الفارغ الذي تُغفله الشريحة
Slide 12 draws a gap between Header and Body but never says what is in the gap. It is an empty line: a CRLF with nothing before it. The receiver reads line by line, and the moment it meets an empty line it knows the header section has ended. Everything after it is body, and Content-Length tells it how many bytes of body to read.
ترسم الشريحة 12 فجوة بين Header وBody لكنها لا تقول أبدًا ما الذي في الفجوة. إنه سطر فارغ: CRLF لا يسبقه شيء. المستقبِل يقرأ سطرًا سطرًا، وفي اللحظة التي يصادف فيها سطرًا فارغًا يعرف أن قسم الترويسات انتهى. كل ما بعده جسم، وContent-Length تخبره كم بايتًا من الجسم عليه أن يقرأ.
Recall
Name the five status code classes, and say what 200, 201 and 404 mean.سمِّ فئات رموز الحالة الخمس، وقل ماذا تعني 200 و201 و404.
Recall
How does a client know where the headers of a response end and how much body to read?كيف يعرف العميل أين تنتهي ترويسات الاستجابة، وكم من الجسم عليه أن يقرأ؟
Quick checkاختبار سريع
In the slide 12 response, what does the value 500 in Content-Length: 500 measure?في استجابة الشريحة 12، ماذا تقيس القيمة 500 في Content-Length: 500؟
Recapالخلاصة
If you remember nothing elseإن لم تتذكر شيئاً آخر فتذكّر هذا
- POST is Create, GET is Read, PUT is Update or Replace, DELETE is Delete; PATCH (slide 19) is a partial update.POST للإنشاء، وGET للقراءة، وPUT للتحديث أو الاستبدال، وDELETE للحذف؛ وPATCH (الشريحة 19) تحديث جزئي.
- GET is safe. GET, PUT and DELETE are idempotent: repeating them leaves the same server state. POST is not.GET آمنة. وGET وPUT وDELETE متساوية الأثر (idempotent): تكرارها يترك حالة الخادم نفسها. أما POST فليست كذلك.
- A request is: request line (method, request target, version), header fields, empty line, optional body.الطلب يتكون من: سطر الطلب (الطريقة، وهدف الطلب، والإصدار)، ثم حقول الترويسة، ثم سطر فارغ، ثم جسم اختياري.
- Host is mandatory in HTTP/1.1; Accept says which media type the client wants back.Host إلزامية في HTTP/1.1؛ وAccept تقول أي نوع وسائط (media type) يريد العميل استلامه.
- A response is: status line (version, status code, reason phrase), header fields, empty line, body.الاستجابة تتكون من: سطر الحالة (الإصدار، ورمز الحالة، وعبارة السبب)، ثم حقول الترويسة، ثم سطر فارغ، ثم الجسم.
- Status classes: 1xx informational, 2xx success, 3xx redirection, 4xx client error, 5xx server error, range 100 to 599.فئات الحالة: 1xx معلوماتية، 2xx نجاح، 3xx إعادة توجيه، 4xx خطأ من العميل، 5xx خطأ من الخادم، والنطاق من 100 إلى 599.
- Content-Type names the body's media type; Content-Length is the body size in bytes, 13 for <html></html>.Content-Type تسمّي نوع وسائط الجسم؛ وContent-Length هو حجم الجسم بالبايتات، وهو 13 لـ <html></html>.
Sourcesالمصادر
- RFC 9110: HTTP SemanticsRFCIETF / RFC EditorSafe and idempotent methods (9.2), Content-Type (8.3), Content-Length (8.6), status code classes and range (15)الطرق الآمنة ومتساوية الأثر (9.2)، وContent-Type (8.3)، وContent-Length (8.6)، وفئات رموز الحالة ونطاقها (15)(opens in a new tab)(يفتح في تبويب جديد)
- RFC 9112: HTTP/1.1RFCIETF / RFC EditorMessage grammar, request line, status line, empty line, mandatory Host headerقواعد صيغة الرسالة، وسطر الطلب، وسطر الحالة، والسطر الفارغ، وترويسة Host الإلزامية(opens in a new tab)(يفتح في تبويب جديد)
- RFC 5789: PATCH Method for HTTPRFCIETF / RFC EditorPATCH versus PUT; PATCH is neither safe nor idempotentPATCH مقابل PUT؛ PATCH ليست آمنة ولا متساوية الأثر(opens in a new tab)(يفتح في تبويب جديد)
- HTTP messagesDocsMDN Web Docs(opens in a new tab)(يفتح في تبويب جديد)
- IdempotentDocsMDN Web DocsIncludes the repeated DELETE returning 200 then 404يتضمن مثال DELETE المكرر الذي يُرجع 200 ثم 404(opens in a new tab)(يفتح في تبويب جديد)