HTTP Status Codes and their Responses

 

status-codes-group

HTTP Status Codes and their Responses

A status code is a piece of information returned by a web server in the HTTP response headers, after receiving a request for a file.

HTTP response status codes indicate whether a specific HTTP request has been successfully completed or not. Responses are grouped in five classes. The first digit of the status code specifies one of five classes of response. An HTTP client must recognize these five classes.

Below is the list of 5 HTTP classes respectively:-

1XX: Informational Responses

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.

S. No. HTTP Status Codes HTTP Status Message Description
1 100 Continue Response indicates that everything so far is OK and that the client should continue with the request or ignore it if it is already finished.
2 101 Switching Protocols This code is sent in response to an Upgrade: request header by the client, and indicates that the protocol the server is switching too.
3 102 Processing This code indicates that the server has received and is processing the request, but no response is available yet

2XX: Success Responses

This class of status codes indicates the action requested by the client was received, understood, accepted, and processed successfully.

S. No. HTTP Status Codes HTTP Status Message Description
4 200 OK Standard response for successful HTTP requests
5 201 Created The request has succeeded and a new resource has been created
6 202 Accepted The request has been received but not yet acted upon.
7 203 Non-Authoritative Information Response code means returned meta-information set is not exact set as available from the origin server, but collected from a local or a third party copy. Except this condition, 200 OK response should be preferred instead of this response.
8 204 No Content The server successfully processed the request and is not returning any content.
9 205 Reset Content The server successfully processed the request, but is not returning any content.
10 206 Partial Content This response code is used because of range header sent by the client to separate download into multiple streams.
11 207 Multi-Status The message body that follows is an XML message and can contain a number of separate response codes, depending on how many sub-requests were made.
12 208 Already Reported The members of a DAV binding have already been enumerated in a previous reply to this request, and are not being included again.
13 226 IM Used The server has fulfilled a request for the resource, and the response is a representation of the result of one or more instance-manipulations applied to the current instance

3XX: Redirection Responses

This class of status code indicates the client must take additional action to complete the request.

S. No. HTTP Status Codes HTTP Status Message Description
14 300 Multiple Choices The request has more than one possible responses.
15 301 Moved Permanently This response code means that URI of requested resource has been changed. Probably, new URI would be given in the response.
16 302 Found This response code means that URI of requested resource has been changed temporarily. New changes in the URI might be made in the future.
17 303 See Other Server sent this response to directing client to get requested resource to another URI with an GET request.
18 304 Not Modified This is used for caching purposes. It is telling to client that response has not been modified. So, client can continue to use same cached version of response.
19 305 Use Proxy This means requested response must be accessed by a proxy. This response code is not largely supported because security reasons.
20 306 Switch Proxy No longer used. Originally meant “Subsequent requests should use the specified proxy
21 307 Temporary Redirect request should be repeated with another URI; however, future requests should still use the original URI
22 308 Permanent Redirect This means that the resource is now permanently located at another URI, specified by theLocation: HTTP Response header

4XX: Client Error Responses

This class of status code is intended for situations in which the client seems to have erred.

S. No. HTTP Status Codes HTTP Status Message Description
23 400 Bad Request This response means that server could not understand the request due to invalid syntax.
24 401 Unauthorized Authentication is needed to get requested response. This is similar to 403, but in this case, authentication is possible.
25 402 Payment Required This response code is reserved for future use. Initial aim for creating this code was using it for digital payment systems however this is not used currently.
26 403 Forbidden Client does not have access rights to the content so server is rejecting to give proper response
27 404 Not Found Server can not find requested resource. This response code probably is most famous one due to its frequency to occur in web.
28 405 Method Not Allowed The request method is known by the server but has been disabled and cannot be used. The two mandatory methods, GET and HEAD, must never be disabled and should not return this error code.
29 406 Not Acceptable The requested resource is capable of generating only content not acceptable according to the Accept headers sent in the request
30 407 Proxy Authentication Required The client must first authenticate itself with the proxy
31 408 Request Timeout The server timed out waiting for the request.
32 409 Conflict Indicates that the request could not be processed because of conflict in the request
33 410 Gone Indicates that the resource requested is no longer available and will not be available again.
34 411 Length Required The request did not specify the length of its content, which is required by the requested resource.
35 412 Precondition Failed The server does not meet one of the preconditions that the requester put on the request.
36 413 Payload Too Large The request is larger than the server is willing or able to process.
37 414 URI Too Long The URI requested by the client is longer than the server is willing to interpret.
38 415 Unsupported Media Type The media format of the requested data is not supported by the server, so the server is rejecting the request.
39 416 Range Not Satisfiable The range specified by the Range header field in the request can’t be fulfilled; it’s possible that the range is outside the size of the target URI’s data.
40 417 Expectation Failed This response code means the expectation indicated by the Expect request header field can’t be met by the server.
41 418 I’m a teapot This code was defined in 1998,and is not expected to be implemented by actual HTTP servers.
42 421 Misdirected Request The request was directed at a server that is not able to produce a response
43 422 Unprocessable Entity The request was well-formed but was unable to be followed due to semantic errors
44 423 Locked The resource that is being accessed is locked.
45 424 Failed Dependency The request failed due to failure of a previous request
46 426 Upgrade Required The server refuses to perform the request using the current protocol but might be willing to do so after the client upgrades to a different protocol.
47 428 Precondition Required The origin server requires the request to be conditional. Intended to prevent “the ‘lost update’ problem, where a client GETs a resource’s state, modifies it, and PUTs it back to the server
48 429 Too Many Requests The user has sent too many requests in a given amount of time.
49 431 Request Header Fields Too Large The server is unwilling to process the request because either an individual header field, or all the header fields collectively, are too large
50 451 Unavailable For Legal Reasons The user requests an illegal resource, such as a web page censored by a government.

5XX: Server Error Responses

Response status codes beginning with the digit “5” indicate cases in which the server is aware that it has encountered an error.

S. No. HTTP Status Codes HTTP Status Message Description
51 500 Internal Server Error The server encountered an unexpected condition which prevented it from fulfilling the request.
52 501 Not Implemented The server does not support the facility required.
53 502 Bad Gateway The server cannot process the request due to a high load
54 503 Service Unavailable This is equivalent to Internal Error 500, but in the case of a server which is in turn accessing some other service, this indicates that the respose from the other service did not return within a time that the gateway was prepared to wait
55 504 Gateway Timeout This error response is given when the server is acting as a gateway and cannot get a response in time.
56 505 HTTP Version Not Supported The HTTP version used in the request is not supported by the server.
57 506 Variant Also Negotiates The server has an internal configuration error: transparent content negotiation for the request results in a circular reference.
58 507 Insufficient Storage The server is unable to store the representation needed to complete the request.
59 508 Loop Detected The server detected an infinite loop while processing the request
60 510 Not Extended Further extensions to the request are required for the server to fulfil it
61 511 Network Authentication Required Status code indicates that the client needs to authenticate to gain network access.

Conclusion :-

These codes are the most important to know and use when producing and consuming RESTful Web Services. The key point to remember is that 2XX is success response, 4XX is the client’s error, and 5XX is the server’s error.

 

 

1 thought on “HTTP Status Codes and their Responses

  • Pingback: homepage

Leave a Reply

Your email address will not be published. Required fields are marked *