Similar to an HTTP Request, an HTTP response is typically a stream of text and possibly data:
It consists of one or more lines of text, terminated by a CRLF (sequential carriage return and line feed characters):
- A status-line indicating the HTTP protocol, the status code, and a textual status
- Optional lines containing the Response Headers. These specify the details of the response or describe the response body
- A blank line, indicating the end of the response metadata
- An optional response body. This will typically be the text of an HTML file, or binary data for an image or other file type, or a block of bytes for streaming data.
The status-line follows the format
Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF
The HTTP-Version indicates the version of the HTTP protocol that is being used (HTTP/1.0, HTTP/1.1, or HTTP/2.0).
SP refers to a space character.
The Status-Code is a three-digit numeric representation of the response status. Common codes include 200 (OK), 404 (Not Found), and 500 (Server Error).
The Reason-Phrase is a plain-text explanation of the status code.
Just like HTTP Requests, a HTTP response can contain headers describing the response. If the response has a body, a Content-Type and Content-Length header would be expected.
A Blank Line
The header section is followed by a blank line (a CRLF with no characters before it). This helps separate the response metadata from the response body.
The full HTTP/1.1 response definition can be found in W3C RFC 2616 Section 6 .