Responses

Anatomy of a response

Read the status line, response headers, blank line, and optional body that a server sends back to an HTTP client.

6 minute lesson

~~~

An HTTP response has a status, headers, and usually a body.

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

<h1>Hello</h1>

The first line contains the protocol version, numeric status code, and a short reason phrase.

Headers describe the response and how clients should handle it. The empty line separates the headers from the body.

The body can contain HTML, JSON, an image, a video, or any other representation. Some responses intentionally have no body. A 204 No Content response is one example; a response to HEAD is another.

Lesson completed