]> granicus.if.org Git - apache/commitdiff
keep the proxied Content-Length header for a HEAD response. PR 18757
authorGreg Ames <gregames@apache.org>
Thu, 20 Oct 2005 21:42:50 +0000 (21:42 +0000)
committerGreg Ames <gregames@apache.org>
Thu, 20 Oct 2005 21:42:50 +0000 (21:42 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@327008 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
server/protocol.c

diff --git a/CHANGES b/CHANGES
index a97405c5b300c1a221197e376be260700cd15119..c8f24017ff7af3ed1e856cb601845cd75f623d5b 100644 (file)
--- 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]
index e440ced1742c215548ec206fdd77fbbf201a789a..7658ef69ac482533087236c22f3efdcd2e51baf7 100644 (file)
@@ -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);
     }