@
forgottencoast #19
1. 按照楼主的提问, 那么肯定是从 http 协议层面考虑, 至于 api 是不是 rest 风格的,没法确定, 没法保证, 没法修改。
2. 其次, 我是没看懂为什么一个动态资源( api )需要实现 head 方法。
按照 mdn 和 rfc2616 的说法,head 方法就是一个 get 方法不返回 body, 主要到作用也是解决带宽和缓存处理。
`实现良好的 RESTful 风格 Api ` 可有任何实际的项目在使用?麻烦发一下 github 地址。
https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Methods/HEAD```
HTTP HEAD 方法 请求资源的头部信息, 并且这些头部与 HTTP GET 方法请求时返回的一致. 该请求方法的一个使用场景是在下载一个大文件前先获取其大小再决定是否要下载, 以此可以节约带宽资源.
```
rfc2616
```
9.4 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.
```