Correct HTTP response code

HTTP response line

status-line = HTTP-version SP status-code SP reason-phrase CRLF

  • status-code = 3DIGIT
  • reason-phrase = * (HTAB / SP / VCHAR / obs-text )

Response code specification : RFC6585 (2012.4), RFC7231 ( 2014.6)

1XX: request has been received, further processing is required to complete, HTTP1.0 not supported

  • 100 Contiune: Before uploading large files
      • Initiated by the client request carries Expect: 100-continue to trigger head
  • 101 Switch Protocols: Protocol upgrade Use
      • The client sends a request to carry Upgrade: head trigger, how to upgrade websocket or http / 2.0
  • 102 Processing: WebDAV request may contain many sub-requests involving file operations take a long time to complete the request. This code indicates that the request server is processing the request, but no response is available. This prevents the client timeout, and assuming the request is lost.

2XX: successfully processed the request

  • 200 OK: successfully returns a response
  • 201 Created: new resources are successfully created on the server side
  • 202 Accepted: The server receives and begins processing the request, the request is outstanding completed. Such a concept is vague by design, can cover more scenarios. Such as asynchronous task processing takes a long time.
  • 204 No Content: successful execution of the request does not carry the response packet body, and hinted that clients do not need to update the current page view. (Used to put, post or the like)
  • 205 Reset Content: execution request without successful response packet carrying the body, and indicates the client to update the current page view.
  • A partial response code is returned in response to the content using the protocol range: 206 Partial Content
  • 207 Multi-Status: RFC4918, return multiple resources WEBDAV XML protocol to the state.
  • 208 Already Reported:RFC5842,为避免相同集合下资源在207响应码下重复上报,使用208可以使用父集合的响应码。

3XX:重定向使用Location指向的资源或者缓存中的资源。在RFC2068中规定客户端重定向次数不应超过5次,以防止死循环。

  • 300 Multiple Choices:资源有多种表述,通过 300 返回给客户端后由其自行选择访问哪一种表述。由于缺乏明确的细节,300很少使用。
  • 301 Moved Permanently:资源永久性重定向到另一个URI中
  • 302 Found:资源临时性重定向到另一个URI中
  • 303 See Other:重定向到其它资源,常用于POST/PUT等方法的响应中。
  • 304 Not Modified:当客户端拥有可能过期的缓存时,会携带缓存表示的etag、时间等信息询问服务器缓存是否仍可复用,而304是告诉客户端可以复用缓存。
  • 307 Temporary Redirect:类似302,但明确重定向后请求方法必须与原请求方法相同,不得改变
  • 308 Permanent Redirect:类似301,但明确重定向后请求方法必须与原请求方法相同,不得改变

Guess you like

Origin www.cnblogs.com/fengxiaoyuan/p/10958679.html