What is the HTTP status code?
HTTP stands for Hypertext Transfer Protocol. It is the method by which clients and servers communicate. When someone clicks a link, types in a URL. Oor submits out a form, their browser sends a request to a server for information. It asks for a page or sending data, but either way, that called an HTTP Request. When a server receives that request, it sends back an HTTP Response, with information for the client. Usually, this is invisible, though you have seen one of the very common Response codes which are as follows:
a) 503 – the server timed out
b) 404 – the requested page doesn’t exist
c) 200 – the server successfully returned the page
There fair few more status codes sent by servers, and the following is a list of the current ones in HTTP 1.1, along with an explanation of their meanings.
1xx: Information
This one type of HTTP status code indicates a provisional response, consisting only of the Status-Line and optional headers, and terminated by an empty line. It does not require headers for this class of status codes. Since HTTP/1.0 did not define any 1xx status codes, servers MUST NOT send a 1xx response to an HTTP/1.0 client except under experimental conditions. A client prepared to accept one or more 1xx status responses prior to a regular response, even if the client does not expect a 100 (Continue) status message. Unexpected 1xx status responses ignored by a user agent. Proxies forward 1xx responses, unless the connection between the proxy and its client closed, or unless the proxy itself requested the generation of the 1xx response.
100 – Continue
This status code tells the client that the first part of the request has received and that it continues with the rest of the request or ignore it if the request has been fulfilled.
101 – Switching Protocols
This status tells the client that the server will switch protocols to that specified in the Upgrade message header field.
2xx: Successful
These status codes indicate success. The body section presents the object returned by the request. It is a MIME format object. It is in MIME format, and may only be in text/plain, text/HTML, or one of the formats specified as acceptable in the request.
200 – OK
The request sent by the client was successful. Generally, this means that the server provided the requested page.
201 – Created
The request successful and a new resource created. The newly created resource reference by the URL(s) returned in the entity of the response, with the most specific URL for the resource given by a Location header field.
202 – Accepted
The request was accepted for processing but has not yet been processed. The request may or may not eventually be acted upon, as it may be not allowed when processing actually takes place. There is no other facility for re-sending a status code from an asynchronous operation.
203 – Non-Authoritative Information
When received in the response to a GET command, this indicates that the returned meta information is not a definitive set of the object from a server with a copy of the object, but is from a private overlaid web. This may include annotation information about the object.
204 – No Content
The server successfully processed the request but isn’t returning any content. This is mainly to allow input for scripts without changing the document at the same time.
205 – Reset Content
The request was successful but the User-Agent should reset the document view that caused the request. This status code primarily intended to allow input for actions to take place via user input, followed by a clearing of the form in which the input given so that the user easily initiate another input action. The response must not include an entity.
206 – Partial Content
The server successfully processed a partial GET request. The status request must have included a Range header field (section 14.35) indicating the desired range and might have included an If-Range header field (section 14.27) to make the request conditional.
3xx: Redirection
These status codes indicate action is needed to fulfill the request. Many times, these status codes are used for redirection. The action required may be carried out by the user agent without interaction with the user if and only if the method used in the second request is GET or HEAD. A client should detect infinite redirection loops since such loops generate network traffic for each redirection.
300 – Multiple Choices
This status code requested resource has multiple possibilities, each with different locations. The server may choose an action based on the requestor (user agent) or the server may present a list so the requestor can choose an action.
301 – Moved Permanently
The resource has permanently moved to a different URL When the server returns this response (as a response to a GET or HEAD request), it automatically forwards the requestor to the new location. The new permanent URL should be given by the Location field in the response.
Unless the request method was HEAD, the entity of the response should contain a short hypertext note with a hyperlink to the new URL(s). If the 301 status code is received in response to a request other than getting or HEAD, the user agent must not automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued.
302 – Found
The requested resource has found under a different URL but the client should continue to use the original URL. This code is similar to a 301 in that for a GET or HEAD request, it automatically forwards the requestor to a different location.
303 – See Other
The server returns this status code when the requestor should make a separate GET request to a different location to retrieve the response. For all requests other than a HEAD request, the server automatically forwards to the other location.
304 – Not Modified
The resource has not modified since the last request. The 304 response does not contain a message-body and thus always terminated by the first empty line after the header fields.
305 – Use Proxy
This status code requested resource only accessed through the proxy specified in the location field. When the server returns this response, it also indicates the proxy that the requestor should use.
306 – No Longer Used
The 306 status code was used in a previous version of the specification, no longer used, and the code reserved.
307 – Temporary Redirect
The resource temporarily moved to a different URL. The client should use the original URL to access the resource in the future as the URL may change. This code is similar to a 301 in that for a GET or HEAD request, it automatically forwards the requestor to a different location.
4xx: Client Error
These HTTP status codes indicate that there was likely an error in the request which prevented the server from being able to process it.
400 – Bad Request
A status code indicates that the server did not understand the request due to bad syntax. The client should not repeat the request without modifications.
401 – Not Authorized
The parameter to this message gives a specification of authorization schemes that are acceptable. The client should retry the request with a suitable Authorization header. If the request already included Authorization credentials, then the 401 response indicates that authorization has refused for those credentials.
If the 401 response contains the same challenge as the prior response, and the user agent has already attempted authentication at least once, then the user should be presented with the entity that was given in the response, since that entity might include relevant diagnostic information.
402 – Payment Required
This status code not currently in use, being listed as reserved for future use.
403 – Forbidden
This status code indicates that the client cannot access the requested resource. That mean that the wrong username and password were sent in the request, or that the permissions on the server do not allow what was being asked.
(This error message indicates that the resource you are trying to access secured with a 128-bit version of Secure Sockets Layer (SSL Certificate). In order to view this resource, you need a browser that supports this level of SSL. Please confirm that your browser supports 128-bit SSL security. If it does, then contact the Web server’s administrator and report the problem).
404 – Not Found
The most common status code from all of them is the 404 status code. This code indicates that the requested resource was not found at the URL given, and the server has no idea how long for it. The 410 (Gone) status code should be used if the server knows, through some internally configurable mechanism, that an old resource is permanently unavailable and has no forwarding address. This status code is mostly used when the server does not wish to reveal exactly why the request has been refused, or when no other response is applicable.
405 – Method Not Allowed
This status code return when the client has tried to use a request method that the server does not allow. Request methods that allow should send with the response (common request methods are POST and GET).
406 – Not Acceptable
This status code means that, although the server understood and processed the request, the response is of a form the client cannot understand. A client sends, as part of a request, headers indicating what types of data it uses, and a 406 error return when the response is of a type not in that list.
407 – Proxy Authentication Required
This status code very similar to the 401 status code and means that the client authorizes by the proxy before the request can proceed.
408 – Request Timeout
This status code means that the client did not produce a request quickly enough. A server set to only wait a certain amount of time for responses from clients, and a 408 status code indicates that time has passed. The client may repeat the request without modifications at any later time.
409 – Conflict
This status code indicates that the server was unable to complete the request, often because a file would to edited, created, or deleted, and that file edited, created, or deleted.
410 – Gone
This status code is the more or less same as 404. It indicates that a resource has permanently gone (a 404 status code gives no indication if a resource has gine permanently or temporarily), and no new address known for it. You should use a 301 to specify the resource’s new location.
411 – Length Required
The server will not accept the request without a valid Content-Length header field.
412 – Precondition Failed
A precondition specified in one or more Request-Header fields returned false.
413 – Request Entity Too Large
This status code indicates that the request was larger than the server is able to handle, either due to physical constraints or to settings. Usually, this occurs when a file sent using the POST method from a form, and the file large than the maximum size allowed in the server settings. If the condition is temporary, the server should include a Retry-After header field to indicate that it is temporary and after what time the client MAY try again
414 – Request URL Too Long
This status code indicates that the URL requested by the client was longer than it can process.
415 – Unsupported Media Type
This status code returned by a server to indicate that part of the request was in an unsupported format.
416 – Requested Range Not Satiable
This status code indicates that the server was unable to fulfill the request. For example, because the client asked for the 650th-800th bytes of a document. But the document was only 200 bytes long.
417 – Expectation Failed
This status code means that the server was unable to properly complete the request. One of the headers sent to the server, the “Expect” header, indicated an expectation the server could not meet.
5xx: Server Error
500 – Internal Server Error
This status code indicates that the server encountered something it didn’t expect and was unable to complete the request.
501 – Not Implemented
This status code indicates the server does not support the functionality required to fulfill the request. This is the appropriate response when the server does not recognize the request method and is not capable of supporting it for any resource.
502 – Bad Gateway
This status code indicates that the server was acting as a gateway or proxy and received an invalid response from the upstream server.
503 – Service Unavailable
This status code most often seen on extremely busy servers. and it indicates that the server was unable to complete the request due to a server overload.
504 – Gateway Timeout
This status code indicates that the server while acting as a gateway or proxy. Did not receive a timely response from the upstream server specified by the URL. Or some other auxiliary server (e.g. DNS) it needed to access in attempting to complete the request.
505 – HTTP Version Not Supported
This status code return when the HTTP version indicated in the request is not supported. The response indicates which HTTP versions supported.