Middle
What does an HTTP request consist of?
sobes.tech AI
Answer from AI
An HTTP request consists of several parts:
- Request Line — contains the method (GET, POST, etc.), URL, and protocol version.
- Headers — key-value pairs that convey meta-information (e.g., Content-Type, Authorization).
- Empty line — separates headers and body.
- Request Body — optional part that contains data (e.g., in a POST request).
Example of a request line and headers:
POST /api/user HTTP/1.1
Host: example.com
Content-Type: application/json
Authorization: Bearer token
{"name":"John"}