Project

General

Profile

Actions

Bug #2344

closed

HEAD requests for 0 byte files do not return the Content-Length header

Added by Frett over 12 years ago. Updated 4 months ago.

Status:
Fixed
Priority:
Normal
Category:
core
Target version:
-
ASK QUESTIONS IN Forums:
No

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

lighttpd.patch (853 Bytes) lighttpd.patch Frett, 2011-09-16 21:14
Actions #1

Updated by stbuehler over 12 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".

Actions #2

Updated by gstrauss about 8 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.

Actions #3

Updated by stbuehler about 8 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.

Actions #4

Updated by stbuehler almost 8 years ago

  • Target version deleted (1.4.x)
Actions #5

Updated by gstrauss 4 months 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.

Actions

Also available in: Atom