Bug #2344
closedHEAD requests for 0 byte files do not return the Content-Length header
Description
with the current 1.4.x branch when making a HEAD request of a 0 byte file the Content-Length header is not sent. This issue has already been addressed in 1.5, I would like to back port the fix to 1.4.x. attached is a patch that makes the change.
in 1.5 the code responsible for the Content-Length header is located in response.c in the http_response_write_header function
Files
Updated by stbuehler over 13 years ago
Not a good idea; a backend doesn't have to generate content for a HEAD request (it could set Content-Length itself for example), and so connections.c might see a file_finished with an empty chunk queue, and must not send "Content-Length: 0".
Updated by gstrauss about 9 years ago
Probably can withdraw this request.
As stbuehler noted, Content-Length response header is not required for HTTP HEAD requests.
Handlers might detect that request method is HEAD and choose to avoid expensive work to generate content, resulting in 0-length data in response queue. Were the method not HEAD, then the response queue might contain non-zero length data.
Therefore, for the case of request method HEAD and an empty response queue, it is probably best if Content-Length is omitted, rather than potentially incorrectly specified as 0.
Updated by stbuehler about 9 years ago
- Status changed from New to Wontfix
It would have been nice to be able to distinguish between "not generated" (no Content-Length header) and "explicitly empty" (Content-Length: 0), but I don't see it coming.
Updated by gstrauss over 1 year ago
- Status changed from Wontfix to Fixed
- ASK QUESTIONS IN Forums set to No
Fixed in lighttpd 1.4.40. http_response_send_file()
sets Content-Length
when sending static files.
Also available in: Atom