From a90554d578154809120ba8909c2b8d5465e6d542 Mon Sep 17 00:00:00 2001 From: Ryan Bloom Date: Wed, 22 Nov 2000 00:40:20 +0000 Subject: [PATCH] Next pass at the content-length filter. Not perfect quite yet, but getting closer Submitted by: Greg Stein git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87058 13f79535-47bb-0310-9956-ffa450edef68 --- include/http_core.h | 2 +- modules/http/http_protocol.c | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/include/http_core.h b/include/http_core.h index 05c15deb21..c66b208a58 100644 --- a/include/http_core.h +++ b/include/http_core.h @@ -121,7 +121,7 @@ extern "C" { #define SATISFY_ANY 1 #define SATISFY_NOSPEC 2 -/* Make sure we don't write less than 4096 bytes at any one time. +/* Make sure we don't write less than 9000 bytes at any one time. */ #define AP_MIN_BYTES_TO_WRITE 9000 diff --git a/modules/http/http_protocol.c b/modules/http/http_protocol.c index bc20adcd11..82ce9ab4f2 100644 --- a/modules/http/http_protocol.c +++ b/modules/http/http_protocol.c @@ -2240,6 +2240,7 @@ AP_DECLARE(void) ap_send_http_header(request_rec *r) struct content_length_ctx { ap_bucket_brigade *saved; int compute_len; + apr_size_t curr_len; }; /* This filter computes the content length, but it also computes the number @@ -2276,10 +2277,11 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_content_length_filter(ap_filter_t *f, else { length = e->length; } + ctx->curr_len += length; r->bytes_sent += length; } - if (r->bytes_sent < AP_MIN_BYTES_TO_WRITE) { + if ((ctx->curr_len < AP_MIN_BYTES_TO_WRITE) && !send_it) { ap_save_brigade(f, &ctx->saved, &b); return APR_SUCCESS; } @@ -2295,9 +2297,9 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_content_length_filter(ap_filter_t *f, */ if ((r->proto_num == HTTP_VERSION(1,1) && !ap_find_last_token(f->r->pool, - apr_table_get(r->headers_out, - "Transfer-Encoding"), - "chunked")) + apr_table_get(r->headers_out, + "Transfer-Encoding"), + "chunked")) || (f->r->connection->keepalive) || (AP_BUCKET_IS_EOS(AP_BRIGADE_LAST(b)))) { ctx->compute_len = 1; @@ -2318,9 +2320,12 @@ AP_CORE_DECLARE_NONSTD(apr_status_t) ap_content_length_filter(ap_filter_t *f, } if (ctx->saved) { AP_BRIGADE_CONCAT(ctx->saved, b); + ap_brigade_destroy(b); b = ctx->saved; + ctx->saved = NULL; } + ctx->curr_len = 0; return ap_pass_brigade(f->next, b); } -- 2.40.0