当前位置:网站首页>Summarize the reasons for 2XX, 3xx, 4xx, 5xx status codes
Summarize the reasons for 2XX, 3xx, 4xx, 5xx status codes
2022-07-05 21:40:00 【51CTO】
1、 The status code tells the result of the request returned from the server
The responsibility of the status code is when the client sends a request to the server , Describe the result of the returned request . With the help of the status code , The user can know that the server is processing the request normally , There are still mistakes .
Category | reason | |
---|---|---|
1XX | Informational( Informational status code ) | Accept request processing |
2XX | Success( Success status code ) | The request is processed normally |
3XX | Redirection( Redirect the status code ) | Additional operations are required to complete the request |
4XX | Client Error( Client error status code ) | The server was unable to process the request |
5XX | Server Error( Server error status code ) | Server processing request error |
1.1、2XX success
2xx The result of the response shows that the request was processed normally .
1.1.1、200 OK
Indicates that the request sent from the client is normally processed in the server . In the response message , The information returned with the status code will change according to different methods . such as :
- Use GET When the method is used , The entity corresponding to the request resource is returned as a response ;
- Use HEAD When the method is used , The entity header corresponding to the request resource does not return with the message body as a response ( That is, only the header is returned in the response , The body of the entity is not returned ).
1.1.2、204 No Content
The status code represents that the request received by the server has been successfully processed , But the main body of the entity is not included in the returned response message . in addition , Nor is it allowed to return the body of any entity . such as : After request processing from browser , return 204 Respond to , Then the page displayed by the browser will not be updated . Generally, you only need to send information from the client to the server , The client does not need to send new information content to use .
1.1.3、206 Partial Content
The status code indicates that the client has made a range request , And the server successfully executed this part of GET request . The response message contains the message from Content-Range Specify the scope of entity content .
1.2、3XX Redirect
3XX The response results show that the browser responds to perform some special processing to correctly process the request .
1.2.1、301 Moved Permanently
Permanent redirection . Changing the status code indicates that the requested resource is allocated to a new URI, In the future, we should use what resources refer to now URI. in other words , If you have mapped resources to URI Saved as bookmark , At this time, we should follow location The first field prompts URI Save again .
1.2.2、302 Found
Temporary redirection . This status code indicates that the requested resource has been allocated a new URI, Hope users ( This time ) Can use the new URI visit . This status code and 301 Moved Permanently The status code is similar , but 302 The resource represented by the status code of is not permanently moved , This is temporary , If the corresponding resource has been moved URI There is a possibility of change in the future . Let's say the user puts URI Bookmark saved , But not like 301 Update the bookmark as the status code appears , But still keep the returned 302 Status code page URI For Bookmarks .
1.2.3、303 See Other
The status code indicates that there is another URI, You should use GET Method to get the requested resource .303 Status codes and 302 The status code has the same function , however 303 The status code clearly indicates that the client should adopt GET Method to get resources , With this 302 The status code is different . such as , When using POST Method access CGI Program , The processing result after its execution is that the client can use GET Method to redirect to another URI On the way up , return 303 Status code . although 302 Found Status codes can also achieve the same function , But here we use 303 The status code is ideal .
When 301、302、303 When the response status code returns , Almost all browsers will put POST Change to GET, And delete the main body in the request message , Then the request will be sent again automatically .
301、302 The standard is to prohibit POST The method is changed to GET Methodical , But in practice, people do it .
1.2.4、304 Not Modified
The status code indicates that when the client sends a conditional request , The server side allows requests to access resources , But after the request fails to meet the conditions , direct
return 304 Not Modified( Server side resources have not changed , You can use the client's unexpired cache directly ).304 When the status code returns , Does not contain the body part of any response .304 Although it is classified as 3XX In category , But it has nothing to do with redirection .
1.2.5、307 Temporary Redirect
Temporary redirection . The status code and 302 Found It has the same meaning . Even though 302 Standard prohibition POST Transform into GET, But in practice, we do not abide by .307 Will follow browser standards , Not from POST become GET. however , For the behavior of processing responses , Each browser may have a different situation .
1.3、4XX Client error
4XX The result of the response shows that the client is the cause of the error .
1.3.1、400 Bad Request
This status code indicates that there is a syntax error in the request message , When a mistake happens , You need to modify the content of the request and send the request again . in addition , Browsers will look like 200 OK Treat the status code as well .
1.3.2、401 Unauthorized
This status code indicates that the sent request needs HTTP authentication (BASIC authentication 、DIGEST authentication ) Authentication information . In addition, if it has been done before 1 Requests , It means that the user authentication fails .
Return contains 401 The response to must contain a... For the requested resource WWW-Authenticate The first one is for questioning (challenge) User information . When the browser first receives 401 Respond to , The dialog window for authentication will pop up .
1.3.3、403 Forbidden
This status code indicates that access to the requested resource has been denied by the server . There is no need for the server to give a detailed reason for rejection , But if you want to explain , The reason can be described in the main part of the entity , So that users can see . Unauthorized access to the file system , There's something wrong with access rights ( Never authorized source IP Address trying to access ) It's possible that 403 Why .
1.3.4、404 Not Found
This status code indicates that the requested resource cannot be found on the server or the server cannot respond without knowing the reason , besides , It can also be used when the server rejects the request and does not want to explain the reason .
1.4、5XX Server error
1.4.1、500 Internal Server Error
The status code indicates that an error occurred on the server side while executing the request . It could be Web Applications exist bug Or some temporary failure .
1.4.2、503 Service Unavailable
The status code indicates that the server is temporarily overloaded or under shutdown maintenance , Can't process the request right now . If you know in advance how long it will take to get rid of the above situation , Best write Retry-After The first field is returned to the client .
1.4.3、504 Gateway Timeout
This status code indicates that the server-side gateway timed out , Unable to process user request .
Be careful : Sometimes the returned status code is not necessarily correct , This user sometimes cannot detect , such as Web An error occurred inside the application , The status code still returns 200 OK, This kind of situation is often encountered .
边栏推荐
- How to send samples when applying for BS 476-7 display? Is it the same as the display??
- PVC plastic sheets BS 476-6 determination of flame propagation properties
- uni-app 蓝牙通信
- 張麗俊:穿透不確定性要靠四個“不變”
- Objects in the list, sorted by a field
- 第05章_存储引擎
- EL与JSTL注意事项汇总
- The primary key is set after the table is created, but auto increment is not set
- [daily training -- Tencent select 50] 89 Gray code (only after seeing the solution of the problem)
- JMeter installation under win7
猜你喜欢
Five layer network protocol
从零开始实现lmax-Disruptor队列(四)多线程生产者MultiProducerSequencer原理解析
Xlrd common operations
Efficiency difference between row first and column first traversal of mat data types in opencv
Arcgis\qgis no plug-in loading (no offset) mapbox HD image map
Exercise 1 simple training of R language drawing
Some common processing problems of structural equation model Amos software
Cross end solution to improve development efficiency rapidly
让开发效率飞速提升的跨端方案
"Grain mall" -- Summary and induction
随机推荐
华为游戏多媒体服务调用屏蔽指定玩家语音方法,返回错误码3010
Teach yourself to train pytorch model to Caffe (2)
Comprehensive optimization of event R & D workflow | Erda version 2.2 comes as "7"
递归查询多级菜单数据
Advantages of robot framework
uni-app 蓝牙通信
R language learning notes
【日常训练】729. 我的日程安排表 I
2.2 basic grammar of R language
Selenium's method of getting attribute values in DOM
Test of incombustibility of cement adhesives BS 476-4
MySQL InnoDB Architecture Principle
Oracle检查点队列–实例崩溃恢复原理剖析
Four components of logger
Defect detection - Halcon surface scratch detection
让开发效率飞速提升的跨端方案
Golang (1) | from environmental preparation to quick start
【日常训练--腾讯精选50】89. 格雷编码(看题解才会的)
sql常用语法记录
Alibaba cloud award winning experience: build a highly available system with polardb-x