The HTTP status code is responsible for representing the return result of the CLIENT HTTP request, marking whether the server processing is normal, and notifying the error.

The status code tells the result of the request returned from the server

The status code of the response describes the processing result of the request. The status code, such as 200 OK, consists of three digits and a reason phrase.

The first digit of the number specifies the response category, and the last two digits are unclassified. There are five response categories.

As long as the definition of the status code category is followed, it is ok to change the status code defined in RFC2616 or create the status code by the server itself.

2 xx success

The response from 2XX indicates that the request was processed normally.

200 OK

Indicates that the request from the client is processed on the server. In the response message, the information returned with the status code may change depending on the method. For example, when the GET method is used, the entity of the requested resource is returned as a response. When the HEAD method is used, the entity HEAD of the requested resource is not returned along with the body of the message.

204 No Content

The status code indicates that the request received by the server is successfully processed, but the response packet returned does not contain the body part of the entity. Also, it is not allowed to return the body of any entity. For example, when a 204 response is returned after processing a request from the browser, the page displayed by the browser is not updated. This is usually used when only information needs to be sent from the client to the server, and no new information content needs to be sent to the client.

206 Partial Content

This status code indicates that the client made a range request and that the server successfully executed that part of the GET request. The response message contains the entity Content in the Range specified by content-range.

3 xx redirection

3XX response results indicate that the browser needs to perform some special processing to properly handle requests.

301 Moved Permanently

Permanent redirect. This status code indicates that the requested resource has been assigned a new URI and that the URI to which the resource now refers should be used later. That is, if the URI corresponding to the resource is already bookmarked, it should be saved again as indicated in the Location header field. As shown in the request URI below, a 301 status code is generated when you forget to add a slash “/” at the end of the specified resource path.

302 Found

Temporary redirection. This status code indicates that the requested resource has been assigned a new URI and is expected to be accessed by the user using the new URI. Similar to 301 Moved Permanently, but the resource represented by the 302 status code is not Permanently Moved but only temporarily. In other words, the URI of a resource that has been moved may change in the future. For example, the user saves the URI as a bookmark, but does not update the bookmark as if the 301 status code were present, but retains the URI of the page that returns the 302 status code.

303 See Other

This status code indicates that because another URI exists for the requested resource, the GET method should be used to GET the requested resource.

When the 301, 302, and 303 response status codes return, almost all browsers change POST to GET and remove the body of the request message, and the request is automatically sent again. Standards 301 and 302 forbid changing POST to GET, but in practice everyone does it.

304 Not Modified

This status code indicates the condition that the server allows the request to access the resource when the client sends request 2 with conditions, but the conditions are not met. The 304 status code returned does not contain any response body. Although 304 is classified as 3XX, it has nothing to do with redirection. A conditional request packet that uses the GET method contains any of if-match, if-modifiedSince, if-none-match, if-range, or if-unmodified-since headers.

307 Temporary Redirect

Temporary redirect. The status code has the same meaning as 302 Found. Although the 302 standard forbids the conversion of POST to GET, it is not followed in practice. 307 will comply with browser standards and will not change from POST to GET. However, each browser may have different situations for the behavior of handling responses.

4XX Client error
400 Bad Request

The status code indicates that a syntax error exists in the request packet. When an error occurs, you need to modify the content of the request and send the request again. In addition, the browser treats the status code as if it were 200 OK.

401 Unauthorized

The status code indicates that the request must be authenticated through HTTP (BASIC authentication or DIGEST authentication). In addition, if the user has been requested once before, the user authentication fails. The response returned with 401 must contain a WWWAuthenticate first Challenge user information applicable to the requested resource. When the browser receives the 401 response for the first time, an authentication dialog will pop up.

403 Forbidden

This status code indicates that access to the requested resource was denied by the server. It is not necessary for the server to give a detailed reason for the rejection, but if it is desired, the reason can be described in the body of the entity so that the user can see it. Not authorized to access the file system, some problems with access permissions (an unauthorized sending source IP address attempts to access), and other listed situations may be the cause of 403.

404 Not Found

This status code indicates that the requested resource could not be found on the server. In addition, it can be used when the server side rejects the request without giving a reason.

5XX Server error
500 Internal Server Error

This status code indicates that an error occurred on the server side while executing the request. It could also be a Web application bug or some temporary glitch.

503 Service Unavailable

This status code indicates that the server is temporarily overloaded or is down for maintenance and is unable to process requests at this time. If you know in advance how long this will take, it is best to write the RetryAfter header field and return it to the client.

Inconsistency between status code and condition Many status code responses returned are incorrect, but the user may not be aware of this. It is not uncommon for the status code to return 200 OK after an error occurs within a Web application.