HTTP, Hypertext Transfer Protocol, is the method by which clients and servers communicate. When someone clicks a link, types in a URL or submits out a form, their browser sends a request to a server for information. It might be asking for a page, or sending data, but either way, that is called an HTTP Request. When a server receives that request, it sends back an HTTP Response, with information for the client. The Response stream also contains a code number usually known as status code or response code, which tells the client in short about what server has returned. There are fairly a large number of 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.
You may also like the following articles:
This class of status code indicates a provisional response, consisting only of the Status-Line and optional headers, and is terminated by an empty line. There are no required headers for this class of status code.
100 - Continue
The status code 100 is used to inform the client that the initial part of the request has been received and has not yet been rejected by the server. The client should continue by sending the remainder of the request.
101 - Switching Protocols
This means that the server is changing to the protocol it defines in the
Upgrade header it returns to the client. The protocol should be switched only when it is advantageous to do so. e.g, switching to a newer version of HTTP is advantageous over older versions.
This class of status code indicates that the client's request was successfully received, understood, and accepted.
200 - OK
This is by far the most common returned. It means, simply, that the request was received and understood and is being processed. Also the information returned with the response is dependent on the method used in the request, for example:
- GET an entity corresponding to the requested resource is sent in the response;
- HEAD the entity-header fields corresponding to the requested resource are sent in the response without any message-body;
- POST an entity describing or containing the result of the action;
- TRACE an entity containing the request message as received by the end server.
201 - Created
A 201 status code means that a request was successful and as a result, a resource has been created. A 201 response may contain an ETag response header field indicating the current value of the entity tag for the requested variant just created.
202 - Accepted
It indicates that server has received and understood the request, and that it has been accepted for processing.The request might or might not eventually be acted upon, as it might be disallowed when processing actually takes place.
203 - Non-Authoritative Information
It means that the request was received and understood, and that information sent back about the response is from a third party, rather than the original server.
204 - No Content
This means that the request was received and understood, but that there is no need to send any data back.
205 - Reset Content
The 205 status code is a request from the server to the client to reset the document from which the original request was sent.
206 - Partial Content
A status code of 206 is a response to a request for part of a document. This is used by advanced caching tools, when a user agent requests only a small part of a page, and just that section is returned.
This class of status code indicates that further action needs to be taken by the user agent in order to fulfill the request.
300 - Multiple Choices
This indicates that a resource has moved. The response will also include a list of locations from which the user agent can select the most appropriate.
301 - Moved Permanently
A status code of 301 tells a client that the resource they asked for has permanently moved to a new location. The response should also include this location. It tells the client to use the new URL the next time it wants to fetch the same resource. This response is cacheable unless indicated otherwise.
302 - Found
A status code of 302 tells a client that the resource they asked for has temporarily moved to a new location. The response should also include this location. It tells the client that it should carry on using the same URL to access this resource.
303 - See Other
It indicates that the response to the request can be found at the specified URL, and should be retrieved from there. It does not mean that something has moved - it is simply specifying the address at which the response to the request can be found.
304 - Not Modified
This is sent in response to a request that asked for the document only if it was newer than the one the client already had. Normally, when a document is cached, the date it was cached is stored. The next time the document is viewed, the client asks the server if the document has changed. If not, the client just reloads the document from the cache.
305 - Use Proxy
It tells the client that the requested resource has to be reached through a proxy, which will be specified in the response.
307 - Temporary Redirect
307 is the status code that is sent when a document is temporarily available at a different URL, which is also returned. There is very little difference between a 302 status code and a 307 status code. 307 was created as another, less ambiguous, version of the 302 status code.
The 4xx class of status code is intended for cases in which the client seems to have erred.
400 - Bad Request
It indicates that the server did not understand the request due to bad syntax.
401 - Unauthorized
This indicates that before a resource can be accessed, the client must be authorised by the server.
402 - Payment Required
The 402 status code is not currently in use, being listed as "reserved for future use".
403 - Forbidden
It indicates that the client cannot access the requested resource. That might 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.
404 - Not Found
The best known of them all, the 404 status code indicates that the requested resource was not found at the URL given, and the server has no idea how long for.
405 - Method Not Allowed
A 405 status code is returned when the client has tried to use a request method that the server does not allow. Request methods that are allowed should be sent with the response (common request methods are POST and GET).
406 - Not Acceptable
It 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 can use, and a 406 error is returned when the response is of a type not i that list.
407 - Proxy Authentication Required
It is very similar to the 401 status code, and means that the client must be authorised by the proxy before the request can proceed.
408 - Request Timeout
This means that the client did not produce a request quickly enough. A server is set to only wait a certain amount of time for responses from clients, and a 408 status code indicates that time has passed.
409 - Conflict
It indicates that the server was unable to complete the request, often because a file would need to be editted, created or deleted, and that file cannot be editted, created or deleted.
410 - Gone
A 410 status code is the 404's lesser known cousin. 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 is known for it.
411 - Length Required
The 411 status code occurs when a server refuses to process a request because a content length was not specified.
412 - Precondition Failed
A 412 status code indicates that one of the conditions the request was made under has failed.
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.
414 - Request-URI Too Long
The 414 status code indicates the the URL requested by the client was longer than it can process.
415 - Unsupported Media Type
A 415 status code is returned by a server to indicate that part of the request was in an unsupported format.
416 - Requested Range Not Satisfiable
A 416 status code indicates that the server was unable to fulfill the request.
417 - Expectation Failed
The 417 status code means that the server was unable to properly complete the request.
Response status codes beginning with the digit "5" indicate cases in which the server is aware that it has erred or is incapable of performing the request.
500 - Internal Server Error
This indicates that the server encountered something it didn't expect and was unable to complete the request.
501 - Not Implemented
It indicates that the server does not support all that is needed for the request to be completed.
502 - Bad Gateway
A 502 status code indicates that a server, while acting as a proxy, received a response from a server further upstream that it judged invalid.
503 - Service Unavailable
A 503 status code is 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
A 504 status code is returned when a server acting as a proxy has waited too long for a response from a server further upstream.
505 - HTTP Version Not Supported
A 505 status code is returned when the HTTP version indicated in the request is no supported. The response should indicate which HTTP versions are supported.