Sobes.tech
Junior — Middle

Can you explain the structure and components of an HTTP request and response?

sobes.tech AI

Answer from AI

An HTTP request consists of three 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, User-Agent).
  3. Body — optional part that contains data, for example, in POST requests.

An HTTP response also has three parts:

  1. Status Line — contains the protocol version, status code (e.g., 200), and a textual description (e.g., OK).
  2. Headers — meta-information about the response (Content-Type, Content-Length, etc.).
  3. Body — data returned by the server to the client (HTML, JSON, images, etc.).

Example of a request start line:

GET /index.html HTTP/1.1

Example of a response start line:

HTTP/1.1 200 OK
Can you explain the structure and components of an… - sobes.tech