Middle+
What does an HTTP request consist of? Name its main parts and blocks.
sobes.tech AI
Answer from AI
An HTTP request consists of several main parts:
-
Request Line — contains the request method (GET, POST, PUT, etc.), the URL (resource path), and the HTTP protocol version.
Example:
GET /index.html HTTP/1.1 -
Headers — a set of key-value pairs that convey additional information about the request, such as content type, authorization, cookies, language, etc.
Example:
Host: example.com User-Agent: Mozilla/5.0 Accept: text/html -
Empty line — separates headers from the body of the request.
-
Body — optional part used to send data to the server, for example, in POST requests with forms or JSON.
Thus, the structure of an HTTP request looks like this:
Request Line
Headers
Body (optional)