Detailed HTTP request line, as well as demonstrate the WebDAV protocol

request-line = method SP request-target SP HTTP-version CRLF

The method of method: the operation specified object, verb

request-target = origin-form / absolute-form /authority-form / asterisk-form 

origin-form = absolute-path [ "?" query ]

  • Initiating a request to the origin server, path must pass empty / 

absolute-form = absolute-URI 

  • Only used when initiating a request to forward proxy proxy

authority-form = authority 

  • Will be used only when the CONNECT method for establishing vpn tunnel and so on. E.g. CONNECT www.example.com:80 HTTP / 1.1

asterisk-form = " * "

  • Only OPTIONS method

HTTP-version version history Development

  • HTTP / 0.9: only supports GET method, outdated
  • HTTP / 1.0: RFC1945,1996, commonly used in a proxy server (e.g. Nginx default)
  • HTTP / 1.1: RFC2616,1999, increasing cache management and control; allows persistent connection; allowing response data block (chunked), facilitate the transmission of large files; mandatory Host header,
  • HTTP / 2.0: 2015.5 released, binary protocol, is no longer a plain text; may initiate multiple requests; header compression using specific algorithms to reduce the amount of data transmission; allows the server actively push data to the client; increased security requirements encrypted communications.

method:

  • GET:主要的获取信息的方法,大量性能优化都针对改方法,幂等方法(幂等方法:调用一次和多次获得的结果是完全一致的)
  • HEAD:类似于GET方法,但是服务器不发送BODY,用以获取HEAD元数据,幂等方法
  • POST:常用于提交HTML FORM表单、新增资源等
  • PUT:更新资源,带条件时是幂等方法
  • DELETE:删除资源,幂等方法
  • CONNECT:建立tunnel隧道
  • OPTIONS:显示服务器对访问资源支持的方法,幂等方法

 如何使用OPTIONS?

linux电脑上默认支持CURL命令,windows上需要安装CURL,安装的方式参考https://jingyan.baidu.com/article/a681b0dec4c67a3b1943467c.html

返回的Allow头部就是服务器对访问资源支持的方法

用于文档管理的WEBDEV方法(RFC2518)

webdav方法也是http方法,只不过为了处理文档协作,专门制作的规范。也可以用于Restful API设计的。

  • PROPFIND:从Web资源中检索以XML格式存储的属性。它也被重载,以允许一个检索远程系统的集合结构(也叫目录层次结构)
  • PROPPATCH:在单个原子性动作中更改和删除资源的多个属性
  • MKCOL:创建集合或者目录
  • COPY:将资源从一个URI复制到另外一个URI
  • MOVE:将资源从一个URI移动到另外一个URI
  • LOCK:锁定一个资源。WebDAV支持共享锁和互斥锁
  • UNLOCK:解除资源的锁定

演示:

1.通过WebDAV协议连接服务器

2.使用连接工具做删、移动、复制文件操作

3.使用WireShark抓到的报文

 

Guess you like

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