Wechat official account: [Dafront-end Yizhan] Follow Dafront-end Yizhan. Questions or suggestions, welcome the public account message.

This is the 19th day of my participation in the August Wenwen Challenge.More challenges in August

The HTTP status code

The HTTP status code is responsible for describing the outcome of the returned request when the client sends a request to the server. The status code lets the user know whether the server handled the request normally or if an error occurred.

A status code, such as 200 OK, consists of a three-digit number and a cause phrase. The first digit specifies the response type, and the last two digits are unclassified:

  • 1XX: Information: the received request is being processed
  • 2XX: Indicates the Success code. The request is successfully processed
  • 3XX: indicates the Redirection status code. Additional operations need to be performed
  • 4XX: Indicates a Client Error code. The server cannot process the request
  • 5XX: Server Error indicates that the Server processes a request incorrectly

There are many kinds of status codes. In fact, there are only about a dozen commonly used status codes. Let’s select representative status codes to introduce them.

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

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

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.

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.

The 303 status code has the same functionality as the 302 Found status code, but differs from the 302 status code in that the 303 status code explicitly states that the client should use the GET method to obtain the resource.

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.

307 Temporary Redirect

Temporary redirect. The status code has the same meaning as 302 Found.

4XX Client error

The 4XX response results indicate that the client is the cause of the 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.

A response returned with 401 must contain a WWW-authenticate 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.

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

The response from 5XX indicates an error occurred on the server itself.

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.














Pay attention to the bottom [Big front End station]
Let’s learn and make progress together

[Share, like, watch] Let more people join us