Sobes.tech
Junior — Middle

What components form the HTTP response?.

sobes.tech AI

Answer from AI

An HTTP response consists of three main components:

  1. Status Line — contains the HTTP protocol version, a numeric status code (e.g., 200, 404), and a textual description of the status (e.g., "OK", "Not Found").

  2. Headers — a set of key-value pairs that convey meta-information about the response, such as content type (Content-Type), content length (Content-Length), date, cookies, and other parameters.

  3. Body — the actual data sent by the server to the client, such as an HTML page, JSON, image, etc.

Example of an HTTP response:

HTTP/1.1 200 OK
Content-Type: text/html; charset=UTF-8
Content-Length: 137

<html>
  <body>
    <h1>Hello, world!</h1>
  </body>
</html>