14 common HTTP status codes

Types of status codes

insert image description here

2XX

200 OK

Indicates that the request sent from the client was processed normally on the server side. In the response message, the information returned together with the status code will vary depending on the method. For example, when using the GET method, the entity corresponding to the requested resource will be returned as a response; while using the HEAD method, the entity header corresponding to the requested resource will not be returned with the message body as a response (that is, only the header will be returned in the response, and the entity's will not be returned. main part).

204 No Content

This status code means that the request received by the server has been successfully processed, but the body part of the entity is not included in the returned response message. Also, it is not allowed to return the body of any entity. For example, when a 204 response is returned after the request is processed from the browser, the page displayed by the browser will not be updated.
Generally , it is used when only information needs to be sent from the client to the server, but no new information needs to be sent to the client .

206 Partial Content

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

3XX

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 in the future. That is to say, if you have already saved the URI corresponding to the resource as a bookmark, you should save it again according to the URI 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 it is hoped that the user (this time) can use the new URI to access.
Similar to the 301 Moved Permanently status code, but the resource represented by the 302 status code is not permanently moved, but only temporary. In other words, the URI corresponding to the 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 when the 301 status code appears, but still retains the URI corresponding to the page that returned the 302 status code.

303 See Other

This status code indicates that because another URI exists for the resource corresponding to the request, the GET method should be used to obtain the requested resource.
The 303 status code and the 302 Found status code have the same function, but the 303 status code clearly indicates that the client should use the GET method to obtain resources, which is different from the 302 status code.
For example, when using the POST method to access a CGI program, and the processing result after execution is to redirect the client to another URI with the GET method, a 303 status code is returned. Although the 302 Found status code can also achieve the same function, it is ideal to use the 303 status code here.

304 Not Modified

This status code indicates that when the client sends a conditional request A, the server allows the request to access the resource, but the condition is not met. When a 304 status code is returned, no response body is included. Although 304 is classified in the 3XX category, it has nothing to do with redirection.

307 Temporary Redirect

Temporary redirection. This status code has the same meaning as 302 Found. Although the 302 standard prohibits the conversion of POST to GET, everyone does not abide by it in actual use.
307 will follow browser standards and will not change from POST to GET. However, each browser may behave differently when it comes to handling responses.

4XX

400 Bad Request

This status code indicates that there is a syntax error in the request message. When an error occurs, it is necessary to modify the content of the request and send the request again. Also, browsers treat this status code like 200 OK.

401 Unauthorized

This status code indicates that the sent request needs to have authentication information that passes HTTP authentication (BASIC authentication, DIGEST authentication). In addition, if a request has been made before, it means that the user authentication has failed.
Responses returned with a 401 MUST include a WWWAuthenticate header applicable to the requested resource to challenge user information. When the browser receives a 401 response for the first time, a dialog window for authentication will pop up.

403 Forbidden

This status code indicates that access to the requested resource has been denied by the server. It is not necessary for the server to give a detailed reason for rejection, but if you want to explain it, you can describe the reason in the body of the entity so that users can see it.
Unauthorized access to the file system, some problems with access rights (attempting to access from an unauthorized source IP address), etc. may be the reasons for 403.

404 Not Found

This status code indicates that the requested resource cannot be found on the server. In addition, it can also be used when the server rejects the request and does not want to explain the reason.

5XX

500 Internal Server Error

This status code indicates that an error occurred on the server side while executing the request. It is also possible that there is a bug in the web application or some temporary failure.

503 Service Unavailable

This status code indicates that the server is temporarily overloaded or down for maintenance, and cannot process requests now. If you know in advance the time required to resolve the above situation, it is best to write the Retry-After header field and return it to the client.

All the above information refer to "Illustrated HTTP".

Guess you like

Origin blog.csdn.net/weixin_45732455/article/details/124553382