Response Messages in HTTP

In this article, we will learn about Response Messages in HTTP.


Let’s begin with a common HTTP response message illustration,

HTTP/1.1 200 OK
Connection: close
Date: Fri, 15 Jul 2022 15: 44 : 04 GMT
Server: Apache/2.2.3 (CentOS)
Last-Modified: Fri, 15 Jul 2022 15:11:03 GMT 
Content-Length: 6821
Content-Type: text/html

[The object that was requested]

It consists of three parts: an initial status line, some header lines and an entity body.

An HTTP response message
An HTTP response message

Status Line

The HTTP version appears first in HTTP response status lines.

Status Code

  • The client is then informed via the status code whether the request was successful or unsuccessful.
  • There are several different status codes,
    • 1xx codes are in the informational category
    • 2xx codes are in the success category
    • 3xx codes are for redirection
    • 4xx is client error
    • 5xx is server error

Here is a summary of several prevalent status codes along with what they mean,

200 OK: The outcome is included in the return message because the request was successful.

404 File Not Found: The server does not have the requested object.

400 Bad Request: The request’s format was such that the server was unable to understand it, according to a general error code.

500 HTTP Internal Server Error: The server encountered an unexpected fault, which prevented the request from being fulfilled.

505 HTTP Version Not Supported: The server does not support the specified HTTP version.

For a complete list, see to pages 39 and 40 of RFC 2616.

Header Lines

Let’s understand the header lines,

  • Connection type: Indicates that the server will stop the TCP connection after sending the response in this instance.
  • Date: The date when the response was produced.
  • Server: Provides information about the server’s software that produced the message. In this instance, it’s Apache.
  • Last-Modified: The most recent modification date of the object being transmitted.
  • Content-Length: The size of the object being sent in 8-bit bytes.
  • Content-Type: Content type. The type of the file is decided by this header and not by the file extension of the object.

The requested file is included in the response’s body.

How HTTP Headers Are Selected

Last but not least, you probably want to know how browsers choose which HTTP headers to include in requests and how servers choose which headers to deliver in responses. That is dependent on a complicated combination of elements including the browser, user settings, and goods.

This all covers the Response Messages in HTTP that one should know about.

Gaurav Karwayun is the founder and editor in chief of CodeIntelligent. He has over 10+ Years of Experience in the software industry. He has experience working in both service and product-based companies. He has vast experience in all popular programming languages, DevOps, Cloud Computing, etc. Follow him on Twitter.

Leave a Comment