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
Re: Apache dropping Content-Length header for HEAD responses where Content-Length is 0 [ In reply to ]
Anyone?

On Fri, Mar 18, 2022 at 12:51 AM Piotr Dobrogost <2022@p.dobrogost.net> wrote:
>
> 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
Re: Apache dropping Content-Length header for HEAD responses where Content-Length is 0 [ In reply to ]
Hi,
I'm reposting my question posted here recently in hope for an answer.


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
Re: Apache dropping Content-Length header for HEAD responses where Content-Length is 0 [ In reply to ]
On Thursday 02 February 2023 at 11:02:26, Piotr Dobrogost wrote:

> 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

Content-length is not a required field for Head responses.

https://www.rfc-editor.org/rfc/rfc9110#section-8.6

Antony.

--
Wanted: telepath. You know where to apply.

Please reply to the list;
please *don't* CC me.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org
Re: Apache dropping Content-Length header for HEAD responses where Content-Length is 0 [ In reply to ]
On Thu, Feb 2, 2023 at 11:12 AM Antony Stone
<Antony.Stone@apache.open.source.it> wrote:
>
> On Thursday 02 February 2023 at 11:02:26, Piotr Dobrogost wrote:
>
> > 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
>
> Content-length is not a required field for Head responses.
>
> https://www.rfc-editor.org/rfc/rfc9110#section-8.6

Ok, but for non-empty files Apache does send Content-Length header in
HEAD responses.
Why does it not send it for empty files?
Treating empty files differently from non-empty files in this case
does not make sense.

Regards,
Piotr Dobrogost

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