HTTP Responses

HTTP Responses

  • An HTTP response is made by a server to a client

  • The aim of the response is to provide the client with the resource it requested, or inform the client that the action it requested has been carried out; or else to inform the client that an error occurred in processing its request

  • An HTTP response contains:

    • A status line

    • A series of HTTP headers, or header fields

    • A message body, which is usually needed


Status Line

  • The status line is the first line in the response message. It consists of at least three items:
  1. The HTTP version number

    • The HTTP specification to which the server has tried to make the message comply.
  2. A status code

    • Three-digit number indicating the result of the request
  3. A reason phrase

    • also known as status text, which is human-readable text that summarizes the meaning of the status code

Example Status Line

HTTP/1.1 200 OK

  • the HTTP version is HTTP/1.1

  • the status code is 200

  • the reason phrase is OK

The Server is responsible for constructing the status line of a request