https://bz.apache.org/bugzilla/show_bug.cgi?id=70176

            Bug ID: 70176
           Summary: mod_proxy drops backend Content-Length: 0 on HEAD
                    responses
           Product: Apache httpd-2
           Version: 2.4-HEAD
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: minor
          Priority: P2
         Component: mod_proxy
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

Apache httpd 2.4.x removes a valid backend-provided Content-Length: 0
from reverse-proxied HEAD responses.

Reproducer:
- Apache httpd 2.4.58 (Ubuntu 24.04)
- mod_proxy + mod_proxy_http
- Backend: Ceph RGW 17.2.7
- A signed S3 HeadObject request for a zero-byte object

Backend response:

HTTP/1.1 200 OK
Content-Length: 0
...

Apache reverse-proxy response:

HTTP/1.1 200 OK
...
# Content-Length is absent

A non-zero Content-Length is preserved through the same ProxyPass route.

The behavior comes from modules/http/http_filters.c,
merge_response_headers():

https://github.com/apache/httpd/blob/2.4.68/modules/http/http_filters.c#L140

if (r->header_only
    && (clheader = apr_table_get(r->headers_out, "Content-Length"))
    && !strcmp(clheader, "0")) {
    apr_table_unset(r->headers_out, "Content-Length");
}

This historical workaround cannot distinguish a core-generated zero
length from an authoritative Content-Length: 0 received by mod_proxy.

Expected behavior:
Preserve backend Content-Length: 0 for reverse-proxied HEAD responses.

Suggested minimal change by removing behavior only for proxy requests:

if (r->proxyreq == PROXYREQ_NONE
    && r->header_only
    && (clheader = apr_table_get(r->headers_out, "Content-Length"))
    && !strcmp(clheader, "0")) {
    apr_table_unset(r->headers_out, "Content-Length");
}

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to