]> granicus.if.org Git - apache/commitdiff
In the content-length+bytes-sent filter, only set the content length
authorJeff Trawick <trawick@apache.org>
Wed, 8 Nov 2000 20:00:35 +0000 (20:00 +0000)
committerJeff Trawick <trawick@apache.org>
Wed, 8 Nov 2000 20:00:35 +0000 (20:00 +0000)
if we decided to do so initially *and* we've seen all the data.

Prior to this change, for a http/1.1 request to mod_autoindex, the
unconditional call to ap_set_content_length() gave us the wrong
value (only taking into account the first brigade) and disabled
chunking.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@86874 13f79535-47bb-0310-9956-ffa450edef68

modules/http/http_protocol.c

index 6993df842eeafa6115b3ad7c5457b1dfc0fce3be..cbfc8e05afcb307a67db2884139ffb579fc0005f 100644 (file)
@@ -2194,7 +2194,8 @@ struct content_length_ctx {
 
 /* This filter computes the content length, but it also computes the number
  * of bytes sent to the client.  This means that this filter will always run
-through all of the buckets in all brigades */
+ * through all of the buckets in all brigades 
+ */
 AP_CORE_DECLARE_NONSTD(apr_status_t) ap_content_length_filter(ap_filter_t *f,
                                                               ap_bucket_brigade *b)
 {
@@ -2240,7 +2241,6 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_content_length_filter(ap_filter_t *f,
         apr_size_t length;
 
         if (AP_BUCKET_IS_EOS(e) || AP_BUCKET_IS_FLUSH(e)) {
-            ctx->hold_data = 0;
             send_it = 1;
         }
         rv = ap_bucket_read(e, &ignored, &length, AP_BLOCK_READ);
@@ -2250,20 +2250,21 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_content_length_filter(ap_filter_t *f,
         r->bytes_sent += length;
     }
 
-    /* save the brigade; we can't pass any data to the next
-     * filter until we have the entire content length
-     */
-    if (ctx->hold_data && !send_it) {
-        ap_save_brigade(f, &ctx->saved, &b);
-        return APR_SUCCESS;
-    }
-
-    if (ctx->saved) {
-        AP_BRIGADE_CONCAT(ctx->saved, b);
-        b = ctx->saved;
+    if (ctx->hold_data) { /* calculating content length? */
+        /* save the brigade; we can't pass any data to the next
+         * filter until we have the entire content length
+         */
+        if (!send_it) {
+            ap_save_brigade(f, &ctx->saved, &b);
+            return APR_SUCCESS;
+        }
+        if (ctx->saved) {
+            AP_BRIGADE_CONCAT(ctx->saved, b);
+            b = ctx->saved;
+        }
+        ap_set_content_length(r, r->bytes_sent);
     }
 
-    ap_set_content_length(r, r->bytes_sent);
     return ap_pass_brigade(f->next, b);
 }