本来计划写一篇浏览器错误码使用的详细总结,近来想了想,第一这不是很深入的知识点、主要还是一种规定;第二对常用的几种的一个使用场景已经有所了解了,所以今天就写一个简单的汇总,并黏贴常用几个错误码的介绍在这里备查。
首先,还是说一下200和304,这两个都是关于读取缓存内容,无需服务端返回的意思。但是两者的区别在于200的cached状态是直接取缓存,304则是请求发送到后端,后端提示可以重定向到缓存。
The request has succeeded. The meaning of a success varies depending on the HTTP method:
GET: The resource has been fetched and is transmitted in the message body.
HEAD: The entity headers are in the message body.
PUT or POST: The resource describing the result of the action is transmitted in the message body.
TRACE: The message body contains the request message as received by the server
 
This is used for caching purposes. It tells the client that the response has not been modified, so the client can continue to use the same cached version of the response.
 
其次,200不带cached就表示请求已成功完成。200系列还有多种状况,都表示已成功的不同状态,在此放几个觉得可能常用的。
 
The request has succeeded. The meaning of a success varies depending on the HTTP method:
GET: The resource has been fetched and is transmitted in the message body.
HEAD: The entity headers are in the message body.
PUT or POST: The resource describing the result of the action is transmitted in the message body.
TRACE: The message body contains the request message as received by the server
 
There is no content to send for this request, but the headers may be useful. The user-agent may update its cached headers for this resource with the new ones.
 
再次,300系列都是关于重定向的,常用的除了上述304,还有301和302,一个是地址永久重定向,一个是地址临时重定向。
 
This response code means that the URI of the requested resource has been changed. Probably, the new URI would be given in the response.
302 Found
This response code means that the URI of requested resource has been changed temporarily. New changes in the URI might be made in the future. Therefore, this same URI should be used by the client in future requests.
 
再次,客户端错误400系列。关于400系列的404和500系列的500/501,两者在某个情况下可能难以区分,就是在请求的资源服务器没有时候返回404,请求的method(get/post/put/head/delete))服务器不支持时显示501,其实笼统的说都有点像服务器不支持当前的这个请求,但是会把前者认为是客户端请求错误,请求了不存在的资源;后者理解为服务端对接口的方法支持的不完全。
另外,对于用不支持的方法请求了不存在的资源,返回501还是404似乎并不确定,似乎可以根据自己的需求来返回对应错误码,但需要注意的是这种情况需要在错误信息中把2种错误都描述进去以提醒用户。
 
The client does not have access rights to the content, i.e. they are unauthorized, so server is rejecting to give proper response. Unlike 401, the client's identity is known to the server.
404 Not Found
The server can not find requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 to hide the existence of a resource from an unauthorized client. This response code is probably the most famous one due to its frequent occurence on the web.
 
最后,服务端错误500系列。
 
The server has encountered a situation it doesn't know how to handle.
501 Not Implemented
The request method is not supported by the server and cannot be handled. The only methods that servers are required to support (and therefore that must not return this code) are GET and HEAD.

Http 状态码(status code)常用总结的更多相关文章

  1. 获取响应状态Status信息、获取状态码Status Code

    一般服务器的响应状态有以下几种: 200 正常 400 未找到页面 403 拒绝 500 服务器错误 比如我们请求bootstrap中文网, 此时的状态码是200 OK表示正常,后面的from cac ...

  2. Java Web学习总结(21)——http协议响应状态码大全以及常用状态码

    http协议响应状态码大全以及常用状态码 当我们在浏览网页或是在查看服务器日志时,常会遇到3位数字的状态码,这3位数字是什么意思呢?其实,这3位数字是HTTP状态码,用来表示网页服务器HTTP响应状态 ...

  3. AJAX 状态值(readyState)与状态码(status)详解

    总结:status体现的是服务器对请求的反馈,而readystate表明客户端与客户的交互状态过程. 1- AJAX状态值与状态码区别AJAX状态值是指,运行AJAX所经历过的几种状态,无论访问是否成 ...

  4. http状态码status

    status——http状态码 1xx 消息 2xx 成功 3xx 重定向 ▪ 301 Moved Permanently 永久重定向——下回不会再找他了 ▪ 302 Move temporarily ...

  5. HTTP协议 -- 认清协议常用状态码

    HTTP协议作为web服务的基础,理所应当受到重视,但是周围的同事能够讲清楚HTTP协议的凤毛麟角.既然是基础,就应该早一点掌握,所以近半年(2016-2月——2016年6月),不准备学习新技术了.首 ...

  6. 「理解HTTP」之常见的状态码segmentfault

    状态码的职责是当客户端向服务器端发送请求时,描述返回请求结果.借助状态码,用户可以知道服务器端是正常处理了请求,还是出现了什么错误. RFC2616定义的状态码,由3位数字和原因短信组成.数字中的第一 ...

  7. Http状态码(转)

    什么是Http状态码?(转自http://bbs.tui18.com/thread-11597640-1-1.html) 百度百科上解释为:HTTP状态码(HTTP Status Code)是用以表示 ...

  8. 常见的HTTP状态码深入理解

    状态码的职责是当客户端向服务器端发送请求时,描述返回请求结果.借助状态码,用户可以知道服务器端是正常处理了请求,还是出现了什么错误. RFC2616定义的状态码,由3位数字和原因短信组成. 数字中的第 ...

  9. Python自定义状态码枚举类

    在Java里很容易做到自定义有状态码和状态说明的枚举类例如: public enum MyStatus { NOT_FOUND(404, "Required resource is not ...

  10. 接口测试——HttpClient工具的https请求、代理设置、请求头设置、获取状态码和响应头

    目录 https请求 代理设置 请求头设置 获取状态码 接收响应头 https请求 https协议(Secure Hypertext Transfer Protocol) : 安全超文本传输协议, H ...

随机推荐

  1. iOS中 SDWebImage手动清除缓存的方法 技术分享

    1.找到SDImageCache类 2.添加如下方法: - (float)checkTmpSize { float totalSize = 0; NSDirectoryEnumerator *file ...

  2. C++ Primer 有感(异常处理)(四)

    查看普通函数的声明的时候,不可能知道该函数会抛出什么异常,但是在捕获异常的时候要知道一个函数会抛出什么样的异常,以便捕获异常. 异常说明:指定,如果函数抛出异常,抛出的异常将是包含在该说明中的一种,或 ...

  3. Java最最常用的100个类排序(非官方)

    下面这句话是引用"大部分的 Java 软件开发都会使用到各种不同的库.近日我们从一万个开源的 Java 项目中进行分析,从中提取出最常用的 Java 类,这些类有来自于 Java 的标准库, ...

  4. hello 内核模块

    #ifndef __KERNEL__ # define __KERNEL__ #endif #ifndef MODULE # define MODULE #endif #include <lin ...

  5. Spring揭秘 读书笔记 五 容器的启动

    Spring的IoC容器所起的作用,就是生产bean,并维持bean间的依赖关系.它会以某种方式加载Configuration Metadata(通常也就是XML格式的配置信息),然后根据这些信息绑定 ...

  6. H5学习之旅-H5列表(8)

    列表的基本语法 ol:有序列表 ul:无序列表 li:列表项 dl:列表 dt:列表项 dd:列表描述 常用列表 1.无序列表:使用标签 ul,li 属性:disc(默认实心圆) circle (空心 ...

  7. Microsoft Dynamics CRM 2011 JS操作集锦

    1.Xrm.Page.context 用户ID:getUserId() 用户角色:getUserRoles() 用户语言:getUserLcid() 组织名称:getOrgUniqueName() 组 ...

  8. 苹果新的编程语言 Swift 语言进阶(十)--类的继承

    一.类的继承 类能够从其它类继承方法.属性以及其它特性,当一个类从另外的类继承时,继承的类称为子类,它继承的类称为超类.在Swift中,继承是类区别与其它类型(结构.枚举)的基础行为. 1.1 .类的 ...

  9. django-debug-tools 使用

    用django开发很快也很容易,但是很多时候我们的经验并不是很足,就会给自己挖下很多坑,不管是性能问题,还是开发语言使用技巧问题都会给应用的稳定带来危害, 开发之后的调试和调优就显得很重要,今天就尝试 ...

  10. ruby技巧001:求md5散列

    ruby核心库中未包含md5之类的功能,不过在其标准库digest中可以方便的使用该功能: = Digest (from ruby core) ---------------------------- ...