Skip to main content

What is an HTTP response?

An HTTP response is a message that a server sends to a client in reply to an HTTP request in order to convey the result of processing the request.

In simple terms: an HTTP response is what the server "says" to the client after a request.


Why an HTTP response is needed

An HTTP response is needed so the client understands:

  • whether the request succeeded
  • what data the server returned
  • whether an error occurred and what kind

Every HTTP request always ends with an HTTP response, even if that response is an error message.


What working with an HTTP response looks like

  1. The client sends an HTTP request
  2. The server receives and processes it
  3. The server builds an HTTP response
  4. The client receives the response and:
  • displays the page
  • processes the API data
  • shows the user an error

What an HTTP response consists of (in simple terms)

An HTTP response usually contains:

1. Response status

Shows what happened with the request:

  • success
  • client error
  • server error

Examples:

  • 200 OK - everything is fine
  • 404 Not Found - the resource was not found
  • 500 Internal Server Error - a server error

2. Headers

Service information, for example:

  • the data type (HTML, JSON)
  • the response length
  • caching settings

3. Response body

The main data:

  • an HTML page
  • a JSON API response
  • a file
  • an error message

The response body can be absent (for example, with certain statuses).


Real-life example

You ask:

"Give me the profile page"

The server responds:

"Here is the page, status: success"

That is an HTTP response.


Key points for an interview

  • an HTTP response always goes from the server to the client
  • the server never sends a response without a request
  • an HTTP response contains the result, not the request itself

Short answer for an interview

Remember this wording:

An HTTP response is a message that a server sends to a client in reply to an HTTP request, and it contains the status of the request's execution along with the returned data or error information.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.