Junior — Middle
Describe the main components and format of an HTTP request.
sobes.tech AI
Answer from AI
An HTTP request consists of several main components:
- Request line — contains method (GET, POST, PUT, etc.), URI (resource address), and HTTP version.
- Headers — key-value pairs that convey additional information about the request, such as content type (
Content-Type), content length (Content-Length), authorization data, etc. - Blank line — separates headers from the body.
- Request body — optional part containing data sent to the server (e.g., form data or JSON).
Example of an HTTP request:
POST /api/users HTTP/1.1
Host: example.com
Content-Type: application/json
Content-Length: 48
{"name":"Ivan","email":"ivan@example.com"}