#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
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
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;
}
*/
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;
}
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);
}