14 common HTTP status codes returned by the server

When we send a request from the client to the server, the 
server returns the status code to us. 
The status code tells us the status of the server response. 
Through it, we can know whether the current request is successful or if there is any problem  . The
status code is composed of 3 digits and It is composed of reason phrases (such as the most common: 200 OK), 
where the first digit represents the response category, and the response category is divided into five types from 1 to 5 
: In fact, I found that there is also a 600 Unparseable Response Headers starting with 6. 
Indicates that the server does not return the response header, but only returns the entity content. It can also be regarded as a server error status code, but it is definitely not common.

status code Response category reason phrase
1XX Informational status code (Informational) The server is processing the request
2XX Success status code (Success) The request has been processed normally
3XX Redirection status code (Redirection) Additional action required to complete the request
4XX Client Error Status Code (Client Error) The server cannot process the request for client reasons
5XX Server Error Status Code (Server Error) Error processing request due to server reason

The definition of the status code response category must be followed, and the latter two digital servers can be DIYed without any problem. 
RFC2616 (a document used to specify the HTTP protocol standard) standard defines more than 40 kinds, and the extension can reach six There are ten 
types, but there are only fourteen common ones. Let me talk about these 14 representative HTTP status codes.

2XX success

200 OK

Indicates that the request is processed normally by the server. 
The most common is this. 
The information returned with this status code is related to your request method 
, such as a GET request. The requested resource will be returned as a response entity 
and a HEAD request. The information only exists in the header of the response message. , because it does not return the body of the message, only the header of the message

200 OK

204 No Content

Indicates that the request has been successfully processed, but no content is returned (there should be no content returned) 
, that is, there is no message entity in the returned response message (in fact, there is no main part of the message entity). 
After the browser sends the request to the server, it receives When 204 is reached, the browser page will not be updated. 
Generally, it is only used when the client sends information to the server, and the server does not need to return any information to the client.

204 No Content

206 Partial Content

Indicates that the server has completed part of the GET request (the client has made a range request). 
The response message contains the entity content of the range specified by Content-Range

206 Partial Content

3XX redirect

301 Moved Permanently

Permanent redirection means that the requested resource has been permanently moved to another location, 
that is, the resource has been assigned a new URI. The 
new URI should be indicated in the Location header field of the response message. 
As long as it is not a HEAD request, the response entity should contain the new URI. Hyperlinks and short descriptions

301 Moved Permanently

302 Found

Temporary redirection means that the requested resource is temporarily moved to another location. 
The requested resource is temporarily assigned to a new URI 
. It is similar to 301, except that the resource is temporarily moved, and the resource may change in the future 
. Similarly, the new temporary URI SHOULD be prompted in the Location header field of the response message. 
As long as it is not a HEAD request, the response entity SHOULD contain a hyperlink to the new URI and a short description

302 Found

303 See Other

Indicates that there is another URI for the requested resource, and GET should be used to obtain the requested resource  . The
function of 303 is the same as that of 302, except that 303 specifies that the client should use GET to access 
(many browsers before HTTP/1.1 cannot understand 303, but everyone regards 302 as 303 treat, use GET to request new URI)

303 See Other

304 Not Modified

Indicates that when the client sends a conditional request (IF... in the GET method request message), when the condition is not satisfied and 
returns 304, it does not contain any response body. 
Although 304 is divided into 3XX, it has nothing to do with redirection.

304 Not Modified

307 Temporary Redirect

Temporary redirect, has the same meaning 
as 302. Although the 302 standard prohibits POST from becoming GET, no one listens to him. 
307 will follow the standard and will not change from POST to GET 
but handle the response behavior. Each browser may be different

307 Temporary Redirect

4XX Client Error

400 Bad Request

Indicates that there is a syntax error or parameter error in the request message, and the server does not understand that 
the server should not submit this request repeatedly. It 
needs to modify the content of the request and send it again.

400 Bad Request

401 Unauthorized

Indicates that the sent request requires HTTP authentication information or the authentication fails 
. The response to return 401 must contain a WWW-Authenticate header applicable to the requested resource to challenge user information 
. When the browser accepts 401 for the first time, an authentication window will pop up.

401 Unauthorized

403 Forbidden

Indicates  that access to the requested resource was denied by the  server.
The server can explain this, or not 

403 Forbidden

404 Not Found

It means that the server can't find the resource you requested. 
It is also possible that the server just doesn't want to give it to you and then tricks you into not being able to find it (⊙ˍ⊙), 
and most servers play this status code like this.

404 Not Found

5XX server error

500 Internal Server Error

表示服务器执行请求的时候出错了 
可能是Web应用有bug或临时故障 
更有可能是服务器源代码有bug…

500 Internal Server Error

503 Service Unavailable

表示服务器超负载或正停机维护,无法处理请求 
如果服务器知道还需要多长时间,就写入Retry-After首部字段返回

503 Service Unavailable

总结

返回的状态码和状态不一致的情况是有可能发生得 
比如Web应用程序内部错误,但仍然返回 200 OK

  • 200 OK 
    请求正常处理完毕
  • 204 No Content 
    请求成功处理,没有实体的主体返回
  • 206 Partial Content 
    GET范围请求已成功处理
  • 301 Moved Permanently 
    永久重定向,资源已永久分配新URI
  • 302 Found 
    临时重定向,资源已临时分配新URI
  • 303 See Other 
    临时重定向,期望使用GET定向获取
  • 304 Not Modified 
    发送的附带条件请求未满足
  • 307 Temporary Redirect 
    临时重定向,POST不会变成GET
  • 400 Bad Request 
    请求报文语法错误或参数错误
  • 401 Unauthorized 
    需要通过HTTP认证,或认证失败
  • 403 Forbidden 
    请求资源被拒绝
  • 404 Not Found 
    The requested resource could not be found (the server refused without reason)
  • 500 Internal Server Error 
    server failure or web application failure
  • 503 Service Unavailable 
    The server is overloaded or down for maintenance

Original address https://blog.csdn.net/q1056843325/article/details/53147180

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324775829&siteId=291194637