Mailing List Archive

Apache dropping Content-Length header for HEAD responses where Content-Length is 0
Hi,

On freshly installed Apache 2.4.52 on Fedora with default
configuration I'm observing that for HEAD response the Content-Length
header is not being sent for empty files (it is present for non-empty
files). When changing HEAD to GET the header is present for such
files.
Sidney Shek asked very similar question on this list in the past with
no response –
"Apache 2.2 proxy dropping content-length header for HEAD responses
where content-length is 0"
(https://lists.apache.org/thread/vlg8x9rl1ob812rhdj7zlbpgsfz7vvw4).

How I tested this:
[user@hostx ~]$ curl -I http://localhost/x.txt
HTTP/1.1 200 OK
Date: Tue, 15 Mar 2022 22:37:56 GMT
Server: Apache/2.4.52 (Fedora Linux)
Last-Modified: Tue, 15 Mar 2022 22:35:21 GMT
ETag: "0-5da4969829e4e"
Accept-Ranges: bytes
Content-Type: text/plain; charset=UTF-8

[user@hostx ~]$ curl -v http://localhost/x.txt
* Trying 127.0.0.1:80...
* Connected to localhost (127.0.0.1) port 80 (#0)
> GET /x.txt HTTP/1.1
> Host: localhost
> User-Agent: curl/7.79.1
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Date: Tue, 15 Mar 2022 22:38:00 GMT
< Server: Apache/2.4.52 (Fedora Linux)
< Last-Modified: Tue, 15 Mar 2022 22:35:21 GMT
< ETag: "0-5da4969829e4e"
< Accept-Ranges: bytes
< Content-Length: 0
< Content-Type: text/plain; charset=UTF-8
<
* Connection #0 to host localhost left intact

How to configure Apache so that Content-Length header would be sent in
HEAD response when requested resource has no content?

Thank you in advance.

Regards,
Piotr Dobrogost

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org