知识点:HTTP状态码

什么是HTTP状态码?

HTTP状态码的作用是:Web服务器用来告诉客户端,发生了什么事。状态码位于HTTP Response的第一行中,会显示一个”三位数字的状态码“和一个“状态消息”。”三位数字的状态码“便于程序进行处理,“状态消息”方便人解读。

状态码分类

数字 含义
100-101 信息提示
200-206 成功
300-305 重定向
400-415 客户端错误
500-505 服务器错误

几个重要的状态码

#####301: Permanent redirect. Clients making subsequent requests for this resource should use the new URI. Clients should not follow the redirect automatically for POST/PUT/DELETE requests. #####302: Redirect for undefined reason. Clients making subsequent requests for this resource should not use the new URI. Clients should not follow the redirect automatically for POST/PUT/DELETE requests. #####303: Redirect for undefined reason. Typically, ‘Operation has completed, continue elsewhere.’ Clients making subsequent requests for this resource should not use the new URI. Clients should follow the redirect for POST/PUT/DELETE requests.(POST重定向为GET) #####307: Temporary redirect. Resource may return to this location at a later point. Clients making subsequent requests for this resource should use the old URI. Clients should not follow the redirect automatically for POST/PUT/DELETE requests.(需要跟用户询问是否应该在新URI上发起POST方法,也就是说,307是不会把POST转为GET的)