Sobes.tech
Junior — Middle

What are the components of an HTTP request?

sobes.tech AI

Answer from AI

An HTTP request consists of several main parts:

  1. Request Line — contains the method (GET, POST, etc.), URL, and protocol version.

  2. Headers — key-value pairs that convey meta-information (e.g., content type, authorization, cookies).

  3. Body — optional part used to transmit data (e.g., in POST requests).

Example of a request line and headers:

POST /api/users HTTP/1.1
Host: example.com
Content-Type: application/json
Authorization: Bearer token

{"name":"John"}

Here:

  • POST — method
  • /api/users — path
  • HTTP/1.1 — protocol version
  • Headers convey additional information
  • Body contains JSON data of the user.
What are the components of an HTTP request? — QA / QA… - sobes.tech