Common HTTP status codes in-depth understanding

Source: Internet
Author: User
Tags 303 status code error status code http authentication

The role of the status code is to describe the return request result when the client sends a request to the server side. With the status code, the user can know whether the server has handled the request properly, or what error has occurred.

RFC2616 defines the status code, consisting of 3 digits and reason SMS.

The first digit in the number specifies the response category, and the latter two bits are not categorized. The following 5 types of response are available:

Type Reason-phrase Note
1XX Informational An informational status code that indicates that the accepted request is being processed
2XX Success Success status code, indicating that the request is processed properly
3XX Redirection Redirect Status code indicating that additional action is required by the client
4XX Client Error Client Error status code indicating that the server could not process the request
5XX Server Error Server error status code, indicating server processing request error

There are 37 HTTP status codes for the RFC2616 record, plus "webdav" (RFC4918, 5842) and "additional http status codes" (RFC6585), which can reach more than 60 types.

And then the egg, so many HTTP status code, in fact, there are probably only 14 kinds of, this article about the 14 kinds of status code.

2XX Success

This class of status code indicates, the client's request was successfully received, understood, and accepted.

The result of the 2XX response indicates that the request from the client is handled properly on the server side.

OK

Requests are processed successfully, and the server returns results based on different request methods:

    • Get: The corresponding resource for the request is returned as a response.
    • Head: The response header (Entity-header) of the requested corresponding resource is returned as a response, not including the response body (message-body).
    • POST: Returns the result of processing the corresponding request.
204 No Content

The status code indicates that the request received by the server has been processed, but the server does not need to return the response body.

For example, if the client is a browser, and the request returns a 204 response, the page displayed by the browser will not be updated.

206 Partial Content

The status code indicates that the client made a scope request, and the server successfully performed the GET request for this part.

A client-initiated request must contain a field in the request header Range . The service-side response message must contain Content-Range the entity content (entity-bodies) from the specified scope

3XX redirection

This class of status code indicates, further action needs to being taken by the user agent in order to fulfill the Reques T.

3XX response results indicate that the browser needs to perform some special processing to complete the request.

301 Movied Permanently

Permanent redirection. The status code indicates that the requested resource has been assigned a new URI, and later uses the URI that the resource now refers to. And there are different ways of handling it depending on the requested method:

    • Head: The new permanent URI must be indicated in the response header Location field.
    • GET: In addition to having Location fields, you need to enclose the hyperlink text of a persistent URI in the response body.
    • Post: The client should not automatically jump to the URI after sending a POST request and receive a 301 response, and should let the user confirm the jump.

For example, if a URI is already bookmarked in the browser, it should be Location re-saved as the URI of the header field hint.

For example, create a bookmark for your favorite:

Http://wan.bigertech.com

When the bookmark is accessed, the request is redirected to the

Http://wan.meizu.com

and the corresponding bookmark will be changed, pointing tohttp://wan.meizu.com

Don't believe me? Try yourself.

302 Found

Temporary redirection. The status code indicates that the requested resource has been assigned a new URI and expects the user to be able to access the new URI at this time.

Similar to the 301 Moved permanently status code, the 302 status code represents a resource that is not permanently moved but is temporary in nature.

If the user bookmarks a URI, the 302 response is not to update the bookmark like 301.

303 See other

The status code indicates that the requested resource should be obtained by using the Get method because another URI exists for the resource that corresponds to the request. 303 differs from 302 in that 302 is the method that does not change the request, and if the request method is post, the redirected request should also be post. For 303, if you use a POST request, the redirected request should be a GET request.

One thing to note, however, is that many of the previous browsers of the http/1.1 version do not understand the 303 status code correctly, and many of the existing browsers speak 302 responses as 303 responses, and use the Get method to access the Location URI specified in the method, ignoring the original request.

In the RFC2616 there is a relevant paragraph in the original text:

Note:many pre-http/1.1 user agents do not understand the 303 status. When interoperability with such clients are a concern, the 302 status code may are used instead, since most user agents REAC T to a 302 response as described here for 303.

304 Not Modified

The status code indicates that the server side allows requests to access resources, but does not meet the conditions, when the client sends a conditional request. 304 When the status code returns, it does not contain any of the subject parts of the response. A conditional request refers to a request header with a Get method that contains:,,,, and any of the headers If-Match If-Modified-Since If-None-Match If-Range If-Unmodified-Since .

307 Temporary Redirect

Temporary redirection. The status code has a similar meaning to 302 and 303, except that the 307 status code does not specify what request method the client will use to request the redirect address. (302 specifies that the original request method is used, 303 specifies that the Get method is used)

4XX Client Error

The 4xx class of status code is intended for cases in which the client seems to has erred.

4XX response results indicate that the client is the cause of the error

Request

Indicates that there is a syntax error in the request message, causing the server to be unable to understand the request. The client needs to modify the requested content and send the request again.

401 Unauthorized

This status code indicates that the request sent requires authentication information through HTTP authentication (Basic authentication, Digest authentication). Returns a response that contains 401, which must be included in the header WWW-Authenticate to indicate which way the server needs authentication.

When the client requests the resource again, it needs to include the authentication information in the request header Authorization .

More information about certification mandates follow RFC2617

403 Forbidden

The status code indicates that access to the requested resource was rejected by the server. The server does not need to give a detailed reason for the rejection, but if you want to do so, you can describe it in the body part of the entity, so that the user can see it.

No access to the file system, some problems with access rights, a 403 response may occur in situations where an unauthorized sending source IP address attempts to access.

404 Not Found

The status code indicates that the specified resource could not be found on the server. It is often used for the reason that the server does not want to reveal a denial request, or no other response is available.

5XX Server Error

Response status codes beginning with the digit "5″indicate cases in which the server was aware that it had erred or is Inc. Apable of performing the request.

5XX response results indicate that the server itself has an error, or that there is insufficient capacity to process the request.

Internal Server Error

The status code indicates that the server side has encountered an error while executing the request. It is also possible that a bug or some temporary failure exists in the Web application.

503 Service Unavailable

The status code indicates that the server is temporarily over-loaded or is undergoing downtime maintenance and cannot process the request now. If you know beforehand how long it takes to release the above, it is best to write the Retry-After header field back to the client.

Common HTTP status codes in-depth understanding

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.