Junior
What are the parts of an HTTP request?
sobes.tech AI
Answer from AI
An HTTP request consists of the following parts:
- Request Line: Defines the request method, target resource, and HTTP protocol version.
- Headers: Contain additional information about the request, sender, data type, etc.
- Body: Contains data sent to the server, such as form data or JSON object. It is not present in all request types (for example, absent in GET).
Example structure:
GET /resource HTTP/1.1
Host: example.com
User-Agent: Mozilla/5.0
Accept: text/html
In this case, the request line is GET /resource HTTP/1.1, headers are Host, User-Agent, Accept. The body is absent in this GET request.