This article is a guide to chapter 4 of Illustrated HTTP

The status code describes 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 processed the request properly or if there was an error.

Category of the status code

category The reason the phrase
1XX Informational status code The received request is being processed
2XX Success status code The request is successfully processed
3XX Redirection status code Additional action is required to complete the request
4XX Client error status code The server cannot process the request
5XX Server error status code Server request error

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

In short,HTTP status codes add up to more than 60. But Illustrated HTTP covers only 14 commonly used status codes

14 commonly used status codes

Status code meaning supplement
200 OK The request was processed normally
204 No Content The request was processed successfully, but there are no resources to return It is not allowed to return the body of any entity. A 204 response is returned. The page displayed by the browser does not need to be updated

This function is used when the client only needs to send information to the server, but does not need to send new information to the client
206 Partial Content Indicates that the client made a scope request and the server successfully executed the GET request. The response message contains the entity Content in the Range specified by content-range
301 Moved Permanently Permanent redirection. The requested resource has been assigned a new URI(if the resource is bookmarked, the URI will be saved as indicated in the Location header field) A special case: a 301 status code is generated when the specified resource path forgets to add a slash at the end
302 Found Temporary redirection. resources are not permanently moved, only temporarily.(If the URI of a resource is bookmarked, the bookmark is not updated as in 301.) The 302 standard forbids POST to be replaced with GET, but it is not followed in practice
303 See Other The GET method should be used to GET the requested resource because another URI exists for the resource corresponding to the request Is redirected. And 302 redirect is the difference between a customer must use the GET method for resources.
304 Not Modified The server allows access to the resource, but does not return the content body unless the condition is met. But the client must send a conditional request 304 has nothing to do with redirection. The client sends a conditional request that contains if-xxxx in the request header (including if-match if-modified-since if-none-match if-range if-unmodified-since)
307 Temporary Temporary redirect. Same as 302 307 is stricter than 302, and enforces a change from POST to GET. However, each browser may differ in how it behaves when handling a response
400 Bad Request Syntax errors exist in the request packet. You need to correct the errors and send the request again The browser treats the status code as if it were 200 OK
401 Unauthorized (1) If 401 is returned for the first request, the request must have HTTP authentication information

② If the request has been made once before, the user authentication fails.

③ The response returning a 401 must include a WWW-authenticate first challenge user information applicable to the requested resource. When the browser accepts 401 for the first time, an authentication dialog will pop up
HTTP authentication includes BASIC authentication and DIGEST authentication
403 Forbidden 403 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 the reason can be described in the body of the entity for the user to see
404 Not Found Indicates that the requested resource cannot be found on the server. It can also be used when the server rejects the request and does not want to explain why
500 Internal Server Error This indicates that the server is performing the request in error, may be a Web application bug or some temporary fault
503 Service Unavailable 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.