libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] How to specify content-length in a HEAD request


From: Rohit Kota
Subject: [libmicrohttpd] How to specify content-length in a HEAD request
Date: Sun, 5 Nov 2023 21:45:02 +0530

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 this is valid behaviour 
A server MAY send a Content-Length header field in a response to a HEAD request (Section 9.3.2); 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, 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

[Prev in Thread] Current Thread [Next in Thread]