带有 HEAD 请求的 Content-Length 标头? [英] Content-Length header with HEAD requests?

查看:45
本文介绍了带有 HEAD 请求的 Content-Length 标头?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http 规范 介绍了 HEAD 请求:

HEAD 方法与 GET 相同,除了服务器不得在响应中返回消息正文.响应 HEAD 请求的 HTTP 标头中包含的元信息应该与响应 GET 请求的信息相同.

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.

HEAD 请求的响应是否应该包含一个 Content-Length 标头?即使没有响应正文,它是否应该是 GET 请求返回的值?还是应该将 Content-Length 设为 0?

Should the response to a HEAD request contain a Content-Length header? Should it be the value which would be returned on a GET request, even if there is no response body? Or should the Content-Length be 0?

推荐答案

对我来说它看起来像 HTTP 1.1 RFC 非常具体:

To me it looks like the HTTP 1.1 RFC is pretty specific:

内容长度entity-header字段表示entity-body的大小,十进制OCTET 的数量,发送给接收者,或者,在 HEAD 的情况下方法,将被发送的实体主体的大小有请求是 GET.

The Content-Length entity-header field indicates the size of the entity-body, in decimal number of OCTETs, sent to the recipient or, in the case of the HEAD method, the size of the entity-body that would have been sent had the request been a GET.

这篇关于带有 HEAD 请求的 Content-Length 标头?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆