Introduction to the HTTP protocol part of the common sense

1, the status code

  Specific status code can Baidu search, but there is a clear understanding of the general classification status codes

    ---- ------ 1XX status code information received request is being processed

    2XX code ------ ------ success status request is processed normally 

    3XX redirect status ----- ---- additional operations required to fulfill the request

    4XX --- ------- Client Error status code server can not request

    5XX ---- Server Status server processes the request it error ----- error

2, a common status codes often Profile

     100 continue: so far expressed are normal, the client can send a request or ignore this normal response

 2XX : 200 ok 

     204 No Content: The request has been processed successfully, but returns a response message does not contain the main part of the entity, generally require client Duan server to send information without the need to return data when using.

     206 Partial Content: represents the range of the client request, a response packet containing solid content range specified Content-Range

 3XX redirection:

    301 Moved Permanently: permanent redirect

    302 Found: Temporary redirect

    303 See Other: methods and 302 have the same function, but 303 clearly requires client access to resources using GET

    Note: In the HTTP protocol stipulates that do not allow the POST method into GEt method when 301,302 state redirect, but most browsers are redirected into GET method to the POST method in 301,302,303 state

   304 NOt Modified: If the request packet header comprising a number of conditions: For example if_match if-ModifiedSince if_NoneSince if-Range if-Unmodified, if these conditions are not met, then the server returns a status code 304

   307: Temporary Redirect: temporary redirection, and 302 similar to 307 but the difference is not required to redirect the browser to POST request method GET method into

4XX; Client Error:

  400 Bad Request: Request packet contains syntax errors

  401 Unauthorized: The status code indicates the need to request authentication information (the BASIC authentication, DIGEST authentication), if a request had been made previously, then user authentication fails

  403 forbidden: the request is rejected, the server does not need to give reason to refuse

   404 not find

5XX: Server Error type:

   500 internalServer Error: An error occurred while the server is executing requests

   503 Server unavilable: at the server is temporarily overloaded, or the server downtime during maintenance. Unable to process request

Then a detailed and described in detail in RFC 2616 specification:

 

 

 

status code category The reason phrase meaning  
100 Informational (informational status codes) Continue (continue) Received the initial part of the request, the client should continue to request.
101 Informational (informational status codes) Switching Protocols (Switching protocols) N The server instructs the client will be switched to the protocol header Update protocol listed.
         
200 Success (success status code) OK The server successfully processed the request
201 Success (success status code) Created (Created) Request for those who want to create a server object, the resource has been created  
202 Success (success status code) Accepted (Accepted) Request has been accepted, but the server has not yet processed  
203 Success (success status code) Non-Authoritative Information (non-authoritative information) Server transaction has been successfully processed, but the information contained in the entity header is not from the original server, but a copy from a resource  
204 Success (success status code) No Content (no text) Response packet header and contains a status line, but not the main content of the entity , generally only send information to the server from the client, using the case of the client does not need to send a new message content
205 Success (success status code) Reset Content (Reset content) Another major for the browser code. Meaning that the browser should reset all of the HTML form on the current page  
206 Success (success status code) Partial Content (part) Successful implementation of a portion or Range (range) request, a client can be identified by a special header to acquire a part or a document within a range
response message contains a Content-Range, Date, and ETag or Content-Location specified range entity content
         
300 Redirection (Redirect Status Code) Multiple Choices (multiple choice) The client requests a URL pointing to the actual multiple resources. This code is a list of options and return together, then the user can select the option that he wants to use the. The preferred server header contains the URL Location  
301 Redirection (Redirect Status Code) Moved Permanently (permanently removed) Permanent redirect , requested URL has been removed. The response should include a Location URL, location of the resource description now live
302 Redirection (Redirect Status Code) Found (Found) Temporary redirection , the status code 301 is similar to, but here is a temporary removal. Client resources should be temporarily positioning the head given URL Location
303 Redirection (Redirect Status Code) See Other (See Other) Tell the client should obtain resources with another URL. The new URL is a response packet Location header. 303 and 302 status code status codes have the same functionality, but 303 made it clear that the client should use the GET method to obtain resources .
      当 301、302、303 响应状态码返回时,几乎所有的浏览器都会把 POST 改成 GET,并删除请求报文内的主体,之后请求会自动再次发送。
301、302 标准是禁止将 POST 方法改变成 GET 方法的,但实际使用时大家都会这么做
 
304 Redirection(重定向状态码) Not Modified(未修改) 该状态码表示客户端发送附带条件的请求时,服务器允许请求访问资源,但因发生请求未满足条件的情况后,直接返回 304 Not Modified(服务器端资源未改变,可直接使用客户端未过期的缓存)304 状态码返回时,不包含任何响应的主体部分。304 虽然被划分在 3XX 类别中,但是和重定向一点关系也没有
      (附带条件的请求是指采用 GET 方法的请求报文中包含 If-Match,If-Modified-Since,If-None-Match,If-Range,If-Unmodified-Since 中任一首部)  
305 Redirection(重定向状态码) Use Proxy(使用代理) 必须通过代理访问 资源,代理的位置是在 Location 首部中给出的  
306 (未使用)   这个状态码当前并未使用  
307 Redirection(重定向状态码) Temporary Redirect(临时重定向) 和状态码 302 类似。但客户端应该用 Location 首部给出的 URL 对资源进行临时定位。
307 会遵守浏览器标准,不会从 POST 变成 GET
         
400 Client Error(客户端错误状态码) Bad request(坏请求) 告诉客户端它发送了一条异常请求
401 Client Error(客户端错误状态码) Unauthorized(未授权) 与适当的首部一起返回,在客户端获得资源访问权之前,请它进行身份认证
402 Client Error(客户端错误状态码) Payment Required(要求付款) 当前此状态码并未使用,是为未来使用预留的  
403 Client Error(客户端错误状态码) Forbidden(禁止) 服务器拒绝了请求
404 Client Error(客户端错误状态码) Not Found(未找到) 服务器无法找到 所请求的 URL
405 Client Error(客户端错误状态码) Method Not Allowed(不允许使用的方法) 请求中有一个所请求的 URI 不支持的方法。响应中应该包含一个 Allow 首部,以告知客户端所请求的资源支持使用哪些方法  
406 Client Error(客户端错误状态码) Not Acceptable(无法接受) 客户端可以指定一些参数来说明希望接受哪些类型的实体。服务器没有资源与客户端可接受的 URL 相匹配时可使用此代码  
407 Client Error(客户端错误状态码) Proxy Authentication Required(要求进行代理认证) 和状态码 401 类似,但用于需要进行资源认证的代理服务器  
408 Client Error(客户端错误状态码) Request Timeout(请求超时) 如果客户端完成其请求时花费的时间太长,服务器可以回送这个状态码并关闭连接  
409 Client Error(客户端错误状态码) Conflict( 冲突) 发出的请求在资源上造成了一些冲突  
410 Client Error(客户端错误状态码) Gone(消失了) 除了服务器曾持有这些资源之外,与状态码 404 类似  
411 Client Error(客户端错误状态码) Length Required(要求长度指示) 服务器要求在请求报文中包含 Content- Length 首部时会使用这个代码。发起的请求中若没有 Content-Length 首部,服务器 是不会接受此资源请求的  
412 Client Error(客户端错误状态码) Precondition Failed(先决条件失败) 如果客户端发起了一个条件请求, 如果服务器无法满足其中的某个条件,就返回这个响应码  
413 Client Error(客户端错误状态码) Request Entity Too Large(请求实体太大) 客户端发送的实体主体部分比 服务器能够或者希望处理的要大  
414 Client Error(客户端错误状态码) Request URI Too Long(请求 URI 太长) 客户端发送的请求所携带的请求 URL 超过了服务器能够或者希望处理的长度  
415 Client Error(客户端错误状态码) Unsupported Media Type(不支持的媒体类型) 服务器无法理解或不支持客户端所发送的实体的内容类型  
416 Client Error(客户端错误状态码) Requested Range Not Satisfiable(所请求的范围未得到满足) 请求报文请求的是某范围内的指定资源,但那个范围无效,或者未得到满足  
417 Client Error(客户端错误状态码) Expectation Failed(无法满足期望) 请求的 Expect 首部包含了一个预期内容,但服务器无法满足  
         
500 Server Error(服务器错误状态码) Internal Server Error(内部服务器错误) 服务器遇到了一个错误,使其无法为请求提供服务
501 Server Error(服务器错误状态码) Not Implemented(未实现) 服务器无法满足客户端请求的某个功能  
502 Server Error(服务器错误状态码) Bad Gateway(网关故障) 作为代理或网关使用的服务器遇到了来自响应链中上游的无效响应  
503 Server Error(服务器错误状态码) Service Unavailable(未提供此服务) 服务器目前无法为请求提供服务,但过一段时间就可以恢复服务
504 Server Error(服务器错误状态码) Gateway Timeout(网关超时) 与状态码 408 类似,但是响应来自网关或代理,此网关或代理在等待另一台服务器的响应时出现了超时  
505 Server Error(服务器错误状态码) HTTP Version Not Supported(不支持的 HTTP 版本) 服务器收到的请求是以它不支持或不愿支持的协议版本表示的  

在 RFC2616 中定义了 40 种 HTTP 状态码,webDAV ( Web-based Distributed Authoring and Versioning,基于万维网的分布式创作和版本控制)在 RFC4918 和 RFC5842 中,定义了一些特殊的状态码,在 RFC2518、RFC2817、RFC2295、RFC2774、RFC6585 中还额外定义了一些附加的 HTTP 状态码。总共有 60+ 种。具体链接可以见 HTTP状态码 (wikipedia)

webDAV 新增状态码

状态码 类别 原因短语 含义  
102 Informational(信息性状态码) Processing(处理中) 可正常处理请求,但目前是处理中状态。WebDAV请求可能包含许多涉及文件操作的子请求,需要很长时间才能完成请求。该代码表示​​服务器已经收到并正在处理请求,但无响应可用。这样可以防止客户端超时,并假设请求丢失。  
207 Success(成功状态码) Multi-Status(多种状态) 存在多种状态。代表之后的消息体将是一个 XML 消息,并且可能依照之前子请求数量的不同,包含一系列独立的响应代码。  
208 Success(成功状态码) Already Reported(已经响应) DAV绑定的成员已经在(多状态)响应之前的部分被列举,且未被再次包含。  
422 Client Error(客户端错误状态码) Unprocessable Entity(不可处理的实体) 格式正确,内容有误,无法处理响应  
423 Client Error(客户端错误状态码) Locked(被锁定) 资源已被加锁  
424 Client Error(客户端错误状态码) Failed Dependency(失败的依赖) 处理与某请求关联的请求失败,因为不再维持依赖关系。  
507 Server Error(服务器错误状态码) Insufficient Storage(存储空间不足) 服务器无法存储完成请求所必须的内容。这个状况被认为是临时的。  
508 Server Error(服务器错误状态码) Loop Detected(检测到环) 服务器在处理请求时陷入死循环。

  

转载于:https://www.cnblogs.com/xinxianquan/p/11062861.html

Guess you like

Origin blog.csdn.net/weixin_34233679/article/details/93898470