Hello,
We have a use case where content-length needs to be set in the response
headers for a HEAD request. See for example:-
https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadObject.html#API_HeadObject_Examples


According to rfc-9110 section 8.6.6
<https://www.rfc-editor.org/rfc/rfc9110.html#section-8.6-6> this is valid
behaviour
A server MAY send a Content-Length header field in a response to a HEAD
request (Section 9.3.2 <https://www.rfc-editor.org/rfc/rfc9110.html#HEAD>);
a server MUST NOT send Content-Length in such a response unless its field
value equals the decimal number of octets that would have been sent in the
content of a response if the same request had used the GET method.

But from what I gathered here
<https://lists.nongnu.org/archive/html/libmicrohttpd/2019-10/msg00037.html>,
I can set MHD_RF_INSANITY_HEADER_CONTENT_LENGTH to allow this behaviour.
For HEAD requests, I suspect libmicrohttpd is always setting content-length
to 0. So for example when i set content-length to 24 manually I am getting
this.
< HTTP/1.1 200 OK
< Date: Sun, 05 Nov 2023 16:10:44 GMT
< Connection: close
< Last-Modified: Thu, 26 Oct 2023 04:42:56 GMT
< Content-Length: 24
< Content-Length: 0

I suspect the extra content-length is being set by mhd. But as per rfc I
should be able to set content-length manually for a head request.

Thank you

Reply via email to