当前位置:网站首页>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 .
边栏推荐
- Gcc9.5 offline installation
- Robot framework setting variables
- @Validated基础参数校验、分组参数验证和嵌套参数验证
- oracle 控制文件的多路复用
- kingbaseES V8R3数据安全案例之---审计记录清除案例
- Haas506 2.0 development tutorial - Alibaba cloud OTA - PAC firmware upgrade (only supports versions above 2.2)
- 阿里云有奖体验:用PolarDB-X搭建一个高可用系统
- MATLAB | App Designer·我用MATLAB制作了一款LATEX公式实时编辑器
- Huawei fast game failed to call the login interface, and returned error code -1
- Chap2 steps into the palace of R language
猜你喜欢
华为游戏多媒体调用切换房间方法出现异常Internal system error. Reason:90000017
Comprehensive optimization of event R & D workflow | Erda version 2.2 comes as "7"
EBS Oracle 11g 克隆步骤(单节点)
EasyExcel的讀寫操作
Cold violence -- another perspective of objective function setting
Arcgis\qgis no plug-in loading (no offset) mapbox HD image map
华为游戏多媒体服务调用屏蔽指定玩家语音方法,返回错误码3010
2.2 basic grammar of R language
基于 Ingress Controller 在集群外访问 Zadig 自测环境(最佳实践)
EN 438-7 laminated sheet products for building covering decoration - CE certification
随机推荐
SQL knowledge leak detection
Robot framework setting variables
办公遇到的问题--
Establishment of terminal security capability verification environment and penetration test records
uni-app 蓝牙通信
Recursive query of multi-level menu data
Scenario interview: ten questions and ten answers about distributed locks
PIP install beatifulsoup4 installation failed
冯唐“春风十里不如你”数字藏品,7月8日登录希壤!
Sitge joined the opengauss open source community to jointly promote the ecological development of the database industry
Five layer network protocol
MMAP
校招期间 准备面试算法岗位 该怎么做?
854. 相似度为 K 的字符串 BFS
让开发效率飞速提升的跨端方案
[daily training] 729 My schedule I
使用Aspect制作全局异常处理类
华为游戏多媒体调用切换房间方法出现异常Internal system error. Reason:90000017
2022-07-03-cka- latest feedback from fans
JMeter installation under win7