有没有办法阻止Jetty在头部请求上发送内容长度标头?

时间:2016-05-24 16:23:02

标签: servlets jetty servlet-filters embedded-jetty

当HEAD请求返回0作为内容长度时,我正在尝试将数据提供给不喜欢它的设备。实际的GET响应是分块的,所以我没有内容长度。

Jetty自己添加内容长度为0。我尝试使用带有Filter的{​​{1}}来删除标头,但没有为“Content-Length”调用任何标头方法。

有没有办法删除那个标题?

感谢。

1 个答案:

答案 0 :(得分:0)

听起来很可疑。

提起了一个关于它的错误https://github.com/eclipse/jetty.project/issues/596

根据规范 - https://tools.ietf.org/html/rfc7231#section-4.3.2

The HEAD method is identical to GET except that the server MUST NOT
send a message body in the response (i.e., the response terminates at
the end of the header section).  The server SHOULD send the same
header fields in response to a HEAD request as it would have sent if
the request had been a GET, except that the payload header fields
(Section 3.3) MAY be omitted.  This method can be used for obtaining
metadata about the selected representation without transferring the
representation data and is often used for testing hypertext links for
validity, accessibility, and recent modification.

因此,如果您在Transfer-Encoding: chunked的资源上请求HEAD,则确实没有提供Content-Length

相关问题