First, about this article
The article is mainly divided into two parts, the first is the HTTP status code Overview. This is followed by a detailed explanation of the 14 commonly used status codes.
Ii. Overview of HTTP status codes
The responsibility of the status code is to describe the result of the request that is returned when the client sends a request to the server. With the status code, the user can know whether the server handled the request properly or an error occurred.
Status codes such as three digits and a reason phrase.
The first digit in the number specifies the response category, and the latter two bits are not categorized. The following five types of response are available:
|
Category |
Reason Phrases |
1XX |
Informational (Informational status code) |
The accepted request is being processed |
2XX |
Success (Success status code) |
Request normal processing complete |
3XX |
Redirection (Redirected status code) |
Additional action required to complete the request |
4XX |
Client error (Customer fault status code) |
The server cannot process the request |
5XX |
Server error (incorrect status code) |
Server Processing Request Error |
As long as you follow the definition of the status Code category, even if you change the status code defined in RFC2616, or the server creates the status code itself, there is no problem.
Only 40 kinds of HTTP status codes are recorded on RFC2616, and if you add WebDAV (RFC4918, 5842) and additional HTTP status code (RFC6585), the number is more than 60. Although there are a wide variety, there are actually only 14 kinds of commonly used.
Iii. 14 commonly used status codes
1OK,204 No content,206 Partial content
If a network request is initiated, 200 is returned. That is, this time the network request server normal processing, and also in accordance with the requirements of the client returned all the information, but also is Taoxin Potter cut lung confessed. Why is it ' according to client's requirements '? Because if the client is using the Head method to request the network, even if the server can indeed return some entity information, since the client does not actively, the server must not return.
If a network request is initiated, 204 is returned. This time, the network request server is properly processed, but the principal of any entity is not returned. The reason is not allowed, so that the user is not sure whether there is no information can be returned to the client, perhaps, maybe none, but it is unknown. For example, the interface that returns the verification code, originally can return the correct verification code, but the frequent operation, the server will send 204.
If a network request is initiated, 206 is returned. As a description, the client makes a scope request, and the server successfully executes this part of the GET request. The response message contains the entity content specified by the Content-range. 206 is similar to 200, but only 206 can reflect this network request behavior.
2,301 Moved permanently,302 Found,303See other,304 not Modified,307 Temporary Redirect
3,401 Unauthorized,403 Forbidden,404 Not Found
4.Internal Server Error,503 Service unavailable
HTTP status Code