HTTP response status codes indicate whether a specific HTTP request has been successfully completed.
Responses are grouped in five classes:
1. Informational responses (100 – 199)
2. Successful responses (200 – 299)
3. Redirection messages (300 – 399)
4. Client error responses (400 – 499)
5. Server error responses (500 – 599)
Response indicates that the client should continue the request or ignore the response if the request is already finished.
Response to an Upgrade request header from the client and indicates the protocol the server is switching to.
Response code indicates that the server has received and is processing the request, but no response is available yet.
Response code primarily intended to be used with the Link header, letting the user agent start preloading resources while the server prepares a response.
a. 200 (Ok)
The request succeeded which means "success" depends on the HTTP method:
GET: The resource has been fetched and transmitted in the message body.
HEAD: The representation headers are included in the response without any message body.
PUT or POST: The resource describing the result of the action is transmitted in the message body.
TRACE: The message body contains the request message as received by the server.
b. 201 (Created)
The request succeeded, and a new resource was created as a result. This is typically the response sent after POST requests, or some PUT requests.
c. 202 (Accepted)
The request has been received but not yet acted upon. It is intended for cases where another process or server handles the request, or for batch processing.
d. 203 (Non-Authoritative Information)
This response code means the returned metadata is not exactly the same, but is collected from a local or a third-party copy. Except for that specific case, the 200 OK response is preferred to this status.
e. 204 (No content)
There is no content to send for this request, but the headers may be useful. The user agent may update its cached headers for this resource with the new ones.
f. 205 (Reset content)
Tells the user agent to reset content of the document which sent this request.
g. 206 (Partial content)
This response code is used when the Range header is sent from the client to request only part/partial content of a resource.
3. Redirection messages (300 – 399)
a. 300 (Multiple Choices)
The request has more than one possible response. The user agent or user should choose one of them.
b. 301 (Moved Permanently)
The URL of the requested resource has been changed permanently. The new URL is given in the response.
c. 302 (Found)
This response code means that the URI of requested resource has been changed temporarily. Further changes in the URI might be made in the future. Therefore, this same URI should be used by the client in future requests.
d. 303 (see other)
The server sent this response to direct the client to get the requested resource at another URI with a GET request.
a. 400 (Bad Request)
The server cannot or will not process the request due to something that is perceived to be a client side error that include malformed request syntax, invalid request message framing, or deceptive request routing.
b. 401 (Unauthorized)
Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response.
c. 402 (Payment Required)
This response code is reserved for future use. The initial aim for creating this code was using it for digital payment systems, however this status code is used very rarely and no standard convention exists.
d. 403 (Forbidden)
The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server.
e. 404 (Not Found)
The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist.
Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web.
a. 500 (Internal Server Error)
The server has encountered a situation it does not know how to handle.
b. 501 (Not Implemented)
The request method is not supported by the server and cannot be handled. The only methods that servers are required to support (and therefore that must not return this code) are GET and HEAD.
c. 502 (Bad Gateway)
This error response means that the server, while working as a gateway to get a response needed to handle the request, got an invalid response.
d. 503 (Service Unavailable)
The server is not ready to handle the request. Common causes are a server that is down for maintenance or that is overloaded. e. 504 (Gateway Timeout)
This error response is given when the server is acting as a gateway and cannot get a response in time.
f. 505 (HTTP Version Not Supported)
The HTTP version used in the request is not supported by the server.
Questions always asked in interview for these response status.