了解http协议的都知道,http相应都有一个状态码,如何给外行解释这个状态码?
rfc有介绍
code | shortmessage | longmessage |
---|---|---|
100 | Continue | Request received, please continue |
101 | Switching Protocols | Switching to new protocol; obey Upgrade header |
200 | OK | Request fulfilled, document follows |
201 | Created | Document created, URL follows |
202 | Accepted | Request accepted, processing continues off-line |
203 | Non-Authoritative Information | Request fulfilled from cache |
204 | No Content | Request fulfilled, nothing follows |
205 | Reset Content | Clear input form for further input. |
206 | Partial Content | Partial content follows. |
300 | Multiple Choices | Object has several resources – see URI list |
301 | Moved Permanently | Object moved permanently – see URI list |
302 | Found | Object moved temporarily – see URI list |
303 | See Other | Object moved – see Method and URL list |
304 | Not Modified | Document has not changed since given time |
305 | Use Proxy | You must use proxy specified in Location to access this resource. |
307 | Temporary Redirect | Object moved temporarily – see URI list |
400 | Bad Request | Bad request syntax or unsupported method |
401 | Unauthorized | No permission – see authorization schemes |
402 | Payment Required | No payment – see charging schemes |
403 | Forbidden | Request forbidden – authorization will not help |
404 | Not Found | Nothing matches the given URI |
405 | Method Not Allowed | Specified method is invalid for this server. |
406 | Not Acceptable | URI not available in preferred format. |
407 | Proxy Authentication Required | You must authenticate with this proxy before proceeding. |
408 | Request Timeout | Request timed out; try again later. |
409 | Conflict | Request conflict. |
410 | Gone | URI no longer exists and has been permanently removed. |
411 | Length Required | Client must specify Content-Length. |
412 | Precondition Failed | Precondition in headers is false. |
413 | Request Entity Too Large | Entity is too large. |
414 | Request-URI Too Long | URI is too long. |
415 | Unsupported Media Type | Entity body in unsupported format. |
416 | Requested Range Not Satisfiable | Cannot satisfy request range. |
417 | Expectation Failed | Expect condition could not be satisfied. |
500 | Internal Server Error | Server got itself in trouble |
501 | Not Implemented | Server does not support this operation |
502 | Bad Gateway | Invalid responses from another server/proxy. |
503 | Service Unavailable | The server cannot process the request due to a high load |
504 | Gateway Timeout | The gateway server did not receive a timely response |
505 | HTTP Version Not Supported | Cannot fulfill request. |
下面举例说明。
比如老师是一个服务器,可以接受一个班级学生的请求,学生提问,老师回答,不过老师回答之前先说一个数字,大概表示回答的内容。
-
100: 继续 客户端应当继续发送请求。客户端应当继续发送请求的剩余部分,或者如果请求已经完成,忽略这个响应。
小明:老师,请问…… 老师:100,继续说 小明:……
-
101: 转换协议 在发送完这个响应最后的空行后,将会切换到在Upgrade 消息头中定义的那些协议。只有在切换新的协议更有好处的时候才应该采取类似措施。
小明:老师,请问…… 老师:101,please ask in english 小明:teacher, I want to know ……
-
102:继续处理 由WebDAV(RFC 2518)扩展的状态码,代表处理将被继续执行。
我不太懂这个
-
200:请求成功 处理方式:获得响应的内容,进行处理
```
小明:老师,请问什么时候下课
老师:200,讲完这段就下课 -
201:请求完成,结果是创建了新资源。新创建资源的URI可在响应的实体中得到 处理方式:爬虫中不会遇到
小明:老师,这是我的作业(post 请求) 老师:201. (然后老师在交作业的记录里写上了小明的名字)
-
202:请求被接受,但处理尚未完成 处理方式:阻塞等待
小明:老师,这是我的试卷(post 请求) 老师: (老师把试卷放一边,继续判手头的试卷) 202.
-
204:服务器端已经实现了请求,但是没有返回新的信 息。如果客户是用户,则无须为此更新自身的文档视图。 处理方式:丢弃
小红:老师,小明这节课没来 老师: (老师把上课名单划掉小明) 204.
-
300:该状态码不被HTTP/1.0的应用程序直接使用, 只是作为3XX类型回应的默认解释。存在多个可用的被请求资源。 处理方式:若程序中能够处理,则进行进一步处理,如果程序中不能处理,则丢弃
-
301:请求到的资源都会分配一个永久的URL,这样就可以在将来通过该URL来访问此资源 处理方式:重定向到分配的URL
小明:老师,请问什么时候放寒假 老师:301,这个问题问校长去,他就在校长办公室,你去那里找他
-
302:请求到的资源在一个不同的URL处临时保存 处理方式:重定向到临时的URL
小明:老师,请问我们期中考试成绩怎么样 老师:302,这个问题问王老师,其中考试是他帮我代课的。
-
304:请求的资源未更新 处理方式:丢弃
小明:老师,请问我们期中考试成绩怎么样 老师:304,我还没有拿到考试成绩呢
-
400:非法请求 处理方式:丢弃
小明:老师,帮我开个VPN 老师:400,犯法的啊
-
401:未授权 处理方式:丢弃
小明:老师,这是我的退学申请 老师:401,找你的监护人签字先
-
403:禁止 处理方式:丢弃
小明:老师,请问1024网址是多少 老师:403,滚出去
-
404:没有找到 处理方式:丢弃
小明:老师,请问你男朋友是谁? 老师:404,滚出去,老娘单身
-
500:服务器内部错误 服务器遇到了一个未曾预料的状况,导致了它无法完成对请求的处理。一般来说,这个问题都会在的源代码出现错误时出现。
小明:老师,请给我们上课吧 老师:500,教案没带……
-
501:服务器无法识别 服务器不支持当前请求所需要的某个功能。当服务器无法识别请求的方法,并且无法支持其对任何资源的请求。
小明:老师,你的爱豆是谁 老师:501,不懂零零后的语言
-
502:错误网关 作为网关或者工作的服务器尝试执行请求时,从上游服务器接收到无效的响应。
小明:老师,告诉我的年级排名? 老师:502,年级主任给我的成绩单丢了
-
503:服务出错 由于临时的维护或者过载,服务器当前无法处理请求。这个状况是临时的,并且将在一段时间以后恢复。
小明:老师,告诉我的年级排名? 老师:503,年级主任给我的成绩单落家里了,明天再问