Updated on 2023-07-14 GMT+08:00

Parsing a Response

After receiving and interpreting a request message, the server returns an HTTP response message.

A response consists of three parts: status line, response header, and response body.

Status Line

The format of the status line is as follows:

HTTP-Version Status-Code Reason-Phrase CRLF
  • HTTP-Version: version of the HTTP protocol used by the server.
  • Status-Code: status code in the response returned by the server.

    A status code consists of three digits. The first digit defines the class of response. There are five values for the first digit:

    • 1xx: informational. The request was received, continuing process.
    • 2xx: successful. The request was successfully received, understood, and accepted.
    • 3xx: redirection. Further action needs to be taken to complete the request.
    • 4xx: client error. The request contains bad syntax or cannot be fulfilled.
    • 5xx: server error. The server failed to fulfill an apparently valid request.
  • Reason-Phrase: text description of a status code.

Response Header

Table 1 describes the headers in most responses.

Response Body

The response body is in JSON format.