From 374a607001bebac1e8c64833294eac13faa85d97 Mon Sep 17 00:00:00 2001 From: Greg Ames Date: Thu, 20 Oct 2005 21:42:50 +0000 Subject: [PATCH] keep the proxied Content-Length header for a HEAD response. PR 18757 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@327008 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 3 +++ server/protocol.c | 14 +++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index a97405c5b3..c8f24017ff 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,9 @@ Changes with Apache 2.3.0 [Remove entries to the current 2.0 and 2.2 section below, when backported] + *) Preserve the Content-Length header for a proxied HEAD request. + PR 18757 [Greg Ames] + *) mod_cache: Create new filters CACHE_OUT_SUBREQ / CACHE_SAVE_SUBREQ which only differ by the type from CACHE_OUT / CACHE_SAVE to ensure that subrequests to non local resources work again. [Ruediger Pluem] diff --git a/server/protocol.c b/server/protocol.c index e440ced174..7658ef69ac 100644 --- a/server/protocol.c +++ b/server/protocol.c @@ -1302,7 +1302,19 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_content_length_filter( * We can only set a C-L in the response header if we haven't already * sent any buckets on to the next output filter for this request. */ - if (ctx->data_sent == 0 && eos) { + if (ctx->data_sent == 0 && eos && + /* don't whack the C-L if it has already been set for a HEAD + * by something like proxy. the brigade only has an EOS bucket + * in this case, making r->bytes_sent zero. + * + * if r->bytes_sent > 0 we have a (temporary) body whose length may + * have been changed by a filter. the C-L header might not have been + * updated so we do it here. long term it would be cleaner to have + * such filters update or remove the C-L header, and just use it + * if present. + */ + !(r->header_only && r->bytes_sent == 0 && + apr_table_get(r->headers_out, "Content-Length"))) { ap_set_content_length(r, r->bytes_sent); } -- 2.49.0