HTTP Method: GET,POST,HEAD,OPTIONS, PUT, DELETE, TRACE ,CONNECT

HTTP1.0就定义了三种请求方式GET,POST,HEAD。HTTP1.1则新增了OPTIONS, PUT, DELETE, TRACE 和 CONNECT 方法。 

https://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html

  • HEAD
The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response. The metainformation contained in the HTTP headers in response to a HEAD request SHOULD be identical to the information sent in response to a GET request. This method can be used for obtaining metainformation about the entity implied by the request without transferring the entity-body itself. This method is often used for testing hypertext links for validity, accessibility, and recent modification.
 
The response to a HEAD request MAY be cacheable in the sense that the information contained in the response MAY be used to update a previously cached entity from that resource. If the new field values indicate that the cached entity differs from the current entity (as would be indicated by a change in Content-Length, Content-MD5, ETag or Last-Modified), then the cache MUST treat the cache entry as stale.

简单来说就是,HEAD方法与GET类似,但是HEAD并不返回消息体。在一个HEAD请求的消息响应中,HTTP头中包含的元信息应该和一个GET请求的响应消息相同。

这种方法可以用来获取请求中隐含的元信息,而无需传输body本身。这个方法经常用来测试超链接的有效性,可用性和最近修改。 
一个HEAD请求响应可以被缓存,也就是说,响应中的信息可能用来更新之前缓存的实体。如果当前实体缓存实体阈值不同(可通过Content_Length、Content-MD5、ETag或Last-Modified的变化来表明),那么这个缓存被视为过期了。
 

HEAD请求的用法

特别适用在优先的速度和带宽下 
1.检查资源的有效性。 
2.检查超链接的有效性。 
3.检查网页是否被串改。 
4.多用于自动搜索机器人获取网页的标志信息,获取rss种子信息,或者传递安全认证信息等。

  • OPTIONS
  1. https://blog.csdn.net/leikezhu1981/article/details/7402272
  2. http请求发生了两次(options请求)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值