Have you any idea about HTTP Status Lines? HTTP Status Line is nothing but a line that depicts the status of the HTTP request message that your browser transmits to the web server. The response message that the server returns includes this status line, which usually you cannot view.
The HTTP Status line comprises the HTTP protocol version, status code and a short description about the status.
Currently, the version HTTP/1.1 is in use, so usually, the version is the same for all status lines. But, some browsers still use HTTP/1.0. The status code and the description part vary depending on the success and failure of the requests.
Always remember, that the status code is just a part of the status line and not the status line itself.
But, before jumping straightaway to HTTP Status Line and HTTP Status codes, let’s first get an idea about HTTP Messages.
How does HTTP Message exchange happen?
Every day you spend a lot of time browsing and moving from one web page to another in search of a particular resource. But have you ever thought about how in just one click you get all these information on your screen?
Well, it is all because of the Hypertext Transfer Protocol, or HTTP. This protocol makes sure that you can access and transfer all files and data in any form across the internet.
HTTP uses the client-server model.
An HTTP client initiates a new connection and sends a request message to an HTTP server. The server then returns a response message.
After delivering the response, the server closes the connection.
HTTP messages depict how the exchange of information takes place between a web server and a client.
There are only two types of messages, requests that a client sends to trigger an action on the server, and responses, the answer from the server.
The request and response messages are similar in format and structure. Both of them consist of
- A single start line that describes the requests or its status
- An optional set of HTTP headers specifying the request, or defining the body included in the message.
- A blank line.
- An optional message body containing data associated with the request
What is HTTP Response?
What do you do when you get a text from your friend? You respond, right?
Either in the form of text, or emoticons, pictures, etc.
In the same way, the web server also responds to your browser in the form of response messages. HTTP Response is the packet of information that a server sends to the client as a response to an earlier request.
For example, if you type www.stemjar.com in your address bar, your browser will send a request to the server that is hosting this website. The server then returns an HTTP response, which you do not see. Instead, you will see the homepage of our website.
After accepting and interpreting a request message, a server responds with a response message, which consists of,
- A Status Line.
- Zero or more header (General-header | Response-header | Entity-header) fields followed by CLRF (Carriage return followed by a line feed).
- A blank line which depicts the end of the header fields, i.e., a line with nothing preceding the CLRF.
- Optionally, a message body.
What is HTTP Response Status Line?
The initial line of a response message is known as the Status line. It is always a single line.
It is the collective term given to the HTTP version, status code, and reason phrase. It consists of three parts separated by spaces.
- The HTTP Protocol Version, usually HTTP/1.1
- A numeric status code, representing success or failure of the request.
- A textual Reason Phrase that describes the status code
A typical status line looks like HTTP/1.1 200 OK. Here HTTP/1.1 is means the protocol version, 200 specifies the status code and OK is the reason phrase.
You can see the status line in the below image. The top part is the request header, and the lower one is the Response header. The Response part starts with the Status line.
HTTP status codes are standard response codes that a web server returns to the client. They help to diagnose the cause of the problem when a web page or other resource does not load correctly.
The Status-Code element is a three digit numeric result code where the first digit defines the class of response.
The last two figures have no categorization role. The first digit has five values.
- 1xx: Informational – It is a provisional response that server issues while it continues processing the request.
- 2xx: Success – When a server successfully receives, interprets, and accepts the browser request, it returns success codes.
- 3xx: Redirection – It means that more action must be taken to complete the request· 4xx: Client Error – The request contains the wrong syntax, or the server cannot fulfill it.· 5xx: Server Error – The server cannot process a valid request
The Reason-Phrase provides a short description of the Status code. It is human readable and may vary. It is a brief, purely informational description of the status code to help a human understand the HTTP message.
A comprehensive List of HTTP Status Lines
Nowadays, browsers mostly use HTTP/1.1. So, typically, the first portion of the status line does not change.
However, the other two elements, i.e., the status code and the reason phrase depend on the request.
The below list demonstrates the values of the numeric status codes defined for HTTP/1.1 and their respective reason-phrases.
It is not mandatory to use only the below-mentioned phrase; you can change the text or replace it with other sentences.
|100||Continue||Everything is going well, and the client can continue with the request or ignore it if it is already complete.|
|101||Switching Protocols||The Server is ready to change protocols as per the demand of the client.|
|200||OK||It is the standard response for successful requests.|
|201||Created||The request to create a new resource is complete.|
|202||Accepted||The server accepts the request, but it needs to complete the processing.|
|204||No Content||The server successfully processed the request and is not returning any content.|
|205||Reset Content||The client has to set the view of the document again.|
|206||Partial Content||The server is going to transmit only part of the resource as the client sent a range header.|
|300||Multiple Choices||Multiple options for the resource is present from which the client can choose.|
|301||Moved Permanently||The requested page has shifted to a new URL.|
|302||Found||The requested page has moved temporarily to a new URL.|
|303||See Other||The resource can be found at another URL using the GET method.|
|304||Not Modified||The server successfully processed the request and is not returning any content.|
|305||Use Proxy||The client must access the requested URL through the proxy mentioned in the Location header.|
|400||Bad Request||Wrong syntax or invalid formatting in the request.|
|401||Unauthorized||The user needs to enter valid credentials, i.e., username and password.|
|403||Forbidden||The request was valid, but the server will not respond to it due to a permission issue.|
|404||Not Found||The resource is not available on the server.|
|405||Method Not Allowed||The request method is not appropriate to the resource.|
|407||Proxy Authentication Required||Similar to 401, but the proxy server must return a Proxy-Authenticate header.|
|408||Request Time-out||The client was unable to send the request in time.|
|409||Conflict||The server cannot process the request due to a conflict in the current state of the resource.|
|410||Gone||The resource is no longer available and will not be available again.|
|411||Length Required||The request did not specify the length of its content.|
|412||Precondition Failed||Some precondition specified in the request headers was false.|
|413||Request Entity Too Large||The requested document is more extensive than the server wants to handle now.|
|414||Request URI Too Long||The URI is too long.|
|415||Unsupported Media Type||The request is in an unknown format.|
|416||Requested Range Not Satisfiable||Client included an unsatisfiable Range header in the request.|
|417||Expectation Failed||The server is unable to fulfill the requirements of the Expect request-header field.|
|500||Internal Server error||Generic Server error|
|501||Not Implemented||The server doesn’t support functionality to fulfill the request.|
|502||Bad Gateway||It indicates that the original server got an inadequate response from the remote server.|
|503||Service Unavailable||The server cannot respond due to maintenance or overloading.|
|504||Gateway Timeout||It indicates that the server didn’t get a response from the remote server in time.|
|505||HTTP Version Not Supported||The server doesn’t support version of HTTP indicated in request line.|
How is HTTP Status Line different from HTTP Status Codes?
Most users and administrators acknowledge HTTP status lines as merely HTTP status codes. However, it is technically incorrect.
Status Code is just an element of the Status line. For instance, 500 is the status code for internal server error. But the Status line for the same will be
HTTP/1.1 500 Internal server error
The Response message includes Status Line, and the Status Line consists of the Status code.
As a casual website visitor, it might be difficult for you to understand the complexity of the requests and responses happening between your browser and a server far away.
If there is a glitch on your side, you can always eradicate it. But sometimes the problem occurs on the server side. In that case, the status line can help you in knowing what exactly the problem is without scratching your head much.
Also, applications that understand HTTP status codes don’t have to know all of the codes and their meanings. However, these HTTP applications do have to know the categories or classes to which a particular code belongs.