HTTP RFC 9112 says that any response to HEAD request MUST NOT contain message body and Transfer-Encoding MAY be sent:
Transfer-Encoding MAY be sent in a response to a HEAD request or in a 304 (Not Modified) response (Section 15.4.5 of [HTTP]) to a GET request, neither of which includes a message body, to indicate that the origin server would have applied a transfer coding to the message body if the request had been an unconditional GET. This indication is not required, however, because any recipient on the response chain (including the origin server) can remove transfer codings when they are not needed.
However, the same RFC in 7.1 says that if Tansfer-Encoding is chunked it must contain chunk-size, which is message body (and must not be in HEAD response):
The chunked transfer coding wraps content in order to transfer it as a series of chunks, each with its own size indicator, followed by an OPTIONAL trailer section containing trailer fields.
ElasticSearch is sending Transfer-Encoding: chunked
in response to HEAD without chunk-size
and HAProxy does have a problem with it .
How should I interpret it?
HTTP RFC 9112 says that any response to HEAD request MUST NOT contain message body and Transfer-Encoding MAY be sent:
Transfer-Encoding MAY be sent in a response to a HEAD request or in a 304 (Not Modified) response (Section 15.4.5 of [HTTP]) to a GET request, neither of which includes a message body, to indicate that the origin server would have applied a transfer coding to the message body if the request had been an unconditional GET. This indication is not required, however, because any recipient on the response chain (including the origin server) can remove transfer codings when they are not needed.
However, the same RFC in 7.1 says that if Tansfer-Encoding is chunked it must contain chunk-size, which is message body (and must not be in HEAD response):
The chunked transfer coding wraps content in order to transfer it as a series of chunks, each with its own size indicator, followed by an OPTIONAL trailer section containing trailer fields.
ElasticSearch is sending Transfer-Encoding: chunked
in response to HEAD without chunk-size
and HAProxy does have a problem with it https://github/haproxy/haproxy/issues/2836.
How should I interpret it?
Share Improve this question edited Jan 31 at 1:57 Kevin Christopher Henry 49.3k7 gold badges124 silver badges110 bronze badges asked Jan 29 at 13:53 Jiri PencakJiri Pencak 212 bronze badges 1- it solves our problem but is this behavior of elastic correct? is it correct regarding http standards? – Jiri Pencak Commented Jan 30 at 15:26
1 Answer
Reset to default 0Yes, including a Transfer-Encoding: chunked
header in response to a HEAD
request is valid. As you point out, that is explicitly acknowledged in Section 6.1 of RFC 9112.
Section 7.1 doesn't contradict that, it simply defines the grammar used when sending chunked data. But the whole point of HEAD
is to send those headers you would have sent with a GET
, but without a body. So, similarly, Transfer-Encoding: gzip
will give an response empty body, Content-Length
won't match the length (0) of the HEAD
response body, etc. Put differently, the semantics of a HEAD
response are different and the body is not expected to match the headers.
In the issue you mention HAProxy acknowledges that their rejection was a bug, and they provide a fix.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745293518a4621003.html
评论列表(0条)