From: Jeff Trawick Date: Wed, 8 Nov 2000 20:00:35 +0000 (+0000) Subject: In the content-length+bytes-sent filter, only set the content length X-Git-Tag: APACHE_2_0_ALPHA_8~140 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b0f2ef3556f5738f3971d43ac313da01b9e27093;p=apache In the content-length+bytes-sent filter, only set the content length 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 --- diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index 6993df842e..cbfc8e05af 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -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); }