Request line corresponding to the line

Request line

A common method (RFC7231)

 

WEBDAV method for document management (RFC2518) 

 

 

HTTP response line

Wherein, HTTP / 1.1 represents a protocol version; 200 denotes a status code; the OK status is described.

2, the status code

Depending on the type of the response result, roughly classified into the following categories:

2.1 1XX (Info)

Request has been received, further processing is required to complete, HTTP1.0 not supported

The status code indicates the type of the received request and continue processing.

  • 100 Continue: The client must continue to make requests, uploading large files before using
    • Initiated by the client request carries Expect: 100-continue to trigger head
  • 101 Switch Protocols: upgrade protocol used, client asks the server converts the request according to the HTTP protocol version.
    • Initiated by the client request carries Upgrade: head trigger, such as upgrading 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 server has received and is processing the request, but no response is available. This prevents the client timeout, and assuming the request is lost

2.2 2XX (successful response)

The status code indicates the type of the action was successfully received, understood and accepted.

  • 200, that the request is successfully completed, transmits the requested resource to the client.
  • 201 Created: new resources are successfully created on the server side. Tip know the URL of the new file.
  • 202 Accepted: The server receives and begins processing the request, the request is outstanding completed. Such a vague concept is deliberately designed so you can cover more of the scene. Such as asynchronous task processing takes a long time.
  • 203 Non-Authoritative Information: return uncertain or incomplete information.
  • 204 No Content: receiving the request, but returned information is null.
  • 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.
  • 208Already Reported:RFC5842,为避免相同集合下资源在207响应码下重复上报,使用208可以使用父集合的响应码。

2.3 3XX(重定向类)

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

该类型状态码表示为了完成指定的动作,必须接受进一步处理。

  • 300 Multiple Choices:资源有多种表述,通过300返回给客户端后由其自行选择访问哪一种表述。由于缺乏明确的细节,300很少使用。
  • 301 Moved Permanently:资源永久性的重定向到另一个URI中。
  • 302,请求的网页被重定向到新的地址。
  • 303,建议用户访问其他URL或访问方式。
  • 304,自从上次请求后,请求的网页未修改过。
  • 305,请求的资源必须从服务器指定的地址获得。
  • 306,前一版本HTTP中使用的代码,现已不再使用。
  • 307,声明请求的资源临时性删除。

2.4 4XX(客户端错误类)

该类型状态码表示请求包含错误语法或不能正确执行。

  • 400,客户端请求有语法错误。
  • 401,请求未经授权。
  • 402,保留有效ChargeTo头响应。
  • 403,禁止访问,服务器收到请求,但拒绝提供服务。
  • 404,可连接服务器,但服务器无法取得所请求的网页,请求资源不存在。
  • 405,用户在Request-Line字段定义的方法不被允许。
  • 406,根据用户发送的Accept,请求资源不可访问。
  • 407,类似401,用户必须首先在代理服务器上取得授权。
  • 408,客户端没有在用户指定的时间内完成请求。
  • 409,对当前资源状态,请求不能完成。
  • 410,服务器上不再有此资源。
  • 411,服务器拒绝用户定义的Content-Length属性请求。
  • 412,一个或多个请求头字段在当前请求中错误。
  • 413,请求的资源大于服务器允许的大小。
  • 414,请求的资源URL长于服务器允许的长度。
  • 415,请求资源不支持请求项目格式。
  • 416,请求中包含Range请求头字段,在当前请求资源范围内没有range指示值。
  • 417,服务器不满足请求Expect头字段指定的期望值。

2.5 5XX(服务器错误类)

该类型状态码表示服务器或网关错误。

  • 500,服务器错误。
  • 501,服务器不支持请求的功能。
  • 502,网关错误。
  • 503,无法获得服务。
  • 504,网关超时。
  • 505,不支持的http版本。

3、响应头

是对响应的一种限定,包含很多属性。常用的属性有:

  • Location,实现请求重定向。
  • Server,服务器的基本信息。
  • Content-Encoding,服务器发送数据时使用的压缩格式。
  • Content-Language,发送的数据所用的语言。
  • Content-Type,所发送的数据的类型。
  • Content-Length,发送数据的大小。
  • Set-Cookie,把cookie发送到客户端。
  • Last-Modified,指示资源的最后修改日期和时间。

Guess you like

Origin www.cnblogs.com/wqbin/p/12080642.html