Status codes

The response starts with the status code. These codes are also defined and there are a limited number of codes usable in a response. The most important is 200, which says all is OK; the response contains what the request wanted. The codes are always in the range of 100 to 599, contain three digits, and are grouped by the first digit.

  • 1xx: These codes are information codes. They are rarely used but can be very important in some cases. For example, 100 means continue. A server can send this code when it gets a POST request and the server wants to signal the client to send the body of the request because it can process it. Using this code, and the client waiting for this code, may save a lot of bandwidth if properly implemented on the server and also on the client.
  • 2xx: These codes mean success. The request is answered properly, or the requested service was done. There are codes, such as 200, 201, 202, and so on, defined in the standard and there is a description about when to use one or the other.
  • 3xx: These codes mean redirection. One of these codes is sent when the server cannot directly service the request but knows the URL that can. The actual codes can distinguish between a permanent redirect (when it is known that all future requests should be sent to the new URL) and temporary redirect (when any later request should be sent here and possibly served or redirected), but the decision is kept on the server side.
  • 4xx: These are error codes. The most famous code is 404, which means Not Found, that is, the server is not able to respond to the request because the resource is not found. 401 means that the resource to serve the request may be available but it requires authentication. 403 is a code that signals that the request was valid but is still refused to be served by the server.
  • 5xx: These codes are server error codes. When a response holds one of these error codes, the meaning is that there is some error on the server. This error can be temporary, for example, when the server is processing too many requests and cannot respond to a new request with a calculation-intensive response (this is usually signaled by error code 503) or when the feature is not implemented (code 501). The general error code 500 is interpreted as Internal Error, which means that no information, whatsoever, is available about what was going wrong on the server, but it was not going well and hence, no meaningful response.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.139.70.21