如何给外行解释HTTP协议返回的相应状态码

了解http协议的都知道,http相应都有一个状态码,如何给外行解释这个状态码?
rfc有介绍

codeshortmessagelongmessage
100ContinueRequest received, please continue
101Switching ProtocolsSwitching to new protocol; obey Upgrade header
200OKRequest fulfilled, document follows
201CreatedDocument created, URL follows
202AcceptedRequest accepted, processing continues off-line
203Non-Authoritative InformationRequest fulfilled from cache
204No ContentRequest fulfilled, nothing follows
205Reset ContentClear input form for further input.
206Partial ContentPartial content follows.
300Multiple ChoicesObject has several resources – see URI list
301Moved PermanentlyObject moved permanently – see URI list
302FoundObject moved temporarily – see URI list
303See OtherObject moved – see Method and URL list
304Not ModifiedDocument has not changed since given time
305Use ProxyYou must use proxy specified in Location to access this resource.
307Temporary RedirectObject moved temporarily – see URI list
400Bad RequestBad request syntax or unsupported method
401UnauthorizedNo permission – see authorization schemes
402Payment RequiredNo payment – see charging schemes
403ForbiddenRequest forbidden – authorization will not help
404Not FoundNothing matches the given URI
405Method Not AllowedSpecified method is invalid for this server.
406Not AcceptableURI not available in preferred format.
407Proxy Authentication RequiredYou must authenticate with this proxy before proceeding.
408Request TimeoutRequest timed out; try again later.
409ConflictRequest conflict.
410GoneURI no longer exists and has been permanently removed.
411Length RequiredClient must specify Content-Length.
412Precondition FailedPrecondition in headers is false.
413Request Entity Too LargeEntity is too large.
414Request-URI Too LongURI is too long.
415Unsupported Media TypeEntity body in unsupported format.
416Requested Range Not SatisfiableCannot satisfy request range.
417Expectation FailedExpect condition could not be satisfied.
500Internal Server ErrorServer got itself in trouble
501Not ImplementedServer does not support this operation
502Bad GatewayInvalid responses from another server/proxy.
503Service UnavailableThe server cannot process the request due to a high load
504Gateway TimeoutThe gateway server did not receive a timely response
505HTTP Version Not SupportedCannot 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,年级主任给我的成绩单落家里了,明天再问
    
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值