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