preface

404 — To the average person, it’s “four hundred and four,” a decimal number, but to developers, especially web developers, it means that the relevant resource is not found, and it means that it doesn’t exist. If I want to implicitly indicate that something of mine is missing, I can say “my stuff is 404” (cryptography and compression are hidden in its design philosophy). In HTTP architecture system, a status code is important one annulus, it use all kinds of consultation good numeric characters to refer to the client and the server to the situations in the communication, separation at the before and after the end of the current environment, front and back side is in a state of separation, understand each status code refer to enough to speed up the development progress and debugging progress is of great significance.

Solution column of each state code

1. 1XX: Informational Response

Description: Indicates that the response has been received and understood by the server, but further processing is required. This type of status code is usually temporary because it will immediately change to one of the following states: Success (2XX), Redirect (3XX), exception or error (4XX or 5XX)

2XX: Request Success

Description: The request sent by the client is successfully received, understood, and accepted by the server

  • 200 Success (OK) : indicates the standard HTTP request success code. In a GET request, the response contains the entity corresponding to the request. In a POST request, the response contains the entity description or operation result of the entity.
  • 202 Accepted: The server Accepted the request, but has not yet processed it. It may succeed, or it may not be executed, or execution may be disabled
  • 204 No Content: The server successfully processed the request, but returned No Content
  • 205 Reset Content: The server successfully processed the request but did not return any Content, unlike 204: this response requires the client to Reset the document view.
  • Partial Content: The server successfully processed the Partial Content of the request. This status code is usually used for HTTP download tool resumable function or multiple downloads in segments (such as thunderbolt download).

3XX: Redirection

Description: Indicates that the client needs to take further action to complete the request. This status code is often used for URL redirection. The subsequent request address is specified in the Location field of the response

  • Moved Permanently: The requested resource has been Permanently Moved to a new Location, and future references to this resource should use one of its returned URIs, and the new permanent URI will be returned in the Location field — never bother me, go to Mike.
  • 302 Temporarily Moved (Found, Moved Temporarily) : Because the move is temporary, the client will send the request at the same address, and the new temporary URI will be returned in the Location field
  • 303 The requested address has been moved, and the requested address can be found on another URI
  • 304 Not Modified: Indicates that the version of the current resource has Not been Modified after the if-modified-since and if-none-match parameters in the request header are used to determine the cache. In this way, the client does Not need to upload a new resource, and the client still uses the copy of the resource downloaded last time.

4XX: Client errors

Description: Indicates that the error condition may be caused by the client. Unless it is a HEAD request, the server should throw out the detailed explanation entity of the error request to explain the error condition. This error message should tell whether it is a temporary or permanent condition. The client should show the error entity to the user as much as possible.

  • 400 Bad Request: An obvious client error Request (e.g., syntax flaw, Request packet size, invalid Request message fragment, fraudulent Request routing)
  • 401 Unauthorized: This error is similar to 403 Forbidden, except that the user fails to pass authentication in specific authentication situations (for example, login authentication).
  • 403 Forbidden: The server validates the request as valid, but the server rejects the request because the user does not have the right to use the resource.
  • 404 Not Found
  • 405 Method Not Allowed: The request Method does Not support access to the requested resources. For example, you passed me a get method when you clearly needed the POST method
  • The format of the request is determined by the media type redefined by the Content-Type header
  • 408 Request Timeout: The client does not finish sending a Request within the time the server is waiting. The client can resubmit the Request at any time without making any changes.
  • 409 Conflict (Confict) : The request cannot be processed because there is a conflict, such as a conflict with a multiplayer online editing tool

5XX: Server errors

Description: The server cannot complete the request. This status indicates that an error or exception occurs during the processing of the request

  • 500 Internal Server Error: A generic Error message that the Server encountered an unexpected condition (e.g. The server may not have used error handling mechanisms such as try catch to catch and handle error exceptions), unable to give a more specific error message to explain — my fault, but I don’t know what I did wrong
  • The server did Not support a feature that was requested in the current request — Not implemented.
  • 502 Bad Gateway: When a server working as a Gateway or proxy tries to execute a request, it receives an invalid response from the upstream server.
  • 503 Service Unavailable: Due to a temporary request overload, the server cannot process the request. The situation is temporary and will recover After some time. If the delay time is expected, the response contains a retry-after header indicating the delay time

Additional knowledge:

  • Methods the Head: It is almost the same with the get method, but this method request header information resources (header information and the get method header information), not request response entity part contains (even if will be ignored), because the feature of the head method, we can use it to test, obtain relevant “information” to the corresponding resources, to determine the steps, One usage scenario is to get the size of a large file before downloading it. It’s a tentacle feeler, like a scout

Afterword.

My personal understanding is that for most developers, to understand the commonly used status code, a status code frame enough, if it is found that the error is not clear on the wiki or the w3c find can, do not need to rote learning, but it is very important, so I need some attention in the daily development status code refers to the implied meaning, Just as you can’t mix circles without knowing the word “2333”, knowing the status code is a basic attribute for mixing circles.

reference

  • wiki
  • MDN
  • W3C