summaryrefslogtreecommitdiffstats
path: root/modules/filters
diff options
context:
space:
mode:
authorStefan Fritsch <sf@apache.org>2011-07-13 22:38:33 +0200
committerStefan Fritsch <sf@apache.org>2011-07-13 22:38:33 +0200
commit8c0a03454c8c5a7cf90c3961ca9991dc4ac8af88 (patch)
tree77f8f05522b22718f7a01e78f9b3bfc827188ef3 /modules/filters
parentUse APR_UNSPEC to allow startup on IP6-only systems. (diff)
downloadapache2-8c0a03454c8c5a7cf90c3961ca9991dc4ac8af88.tar.xz
apache2-8c0a03454c8c5a7cf90c3961ca9991dc4ac8af88.zip
Don't try to compress requests with a zero sized body.
PR: 51350 git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1146418 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/filters')
-rw-r--r--modules/filters/mod_deflate.c26
1 files changed, 24 insertions, 2 deletions
diff --git a/modules/filters/mod_deflate.c b/modules/filters/mod_deflate.c
index a11c6022be..2f186433b7 100644
--- a/modules/filters/mod_deflate.c
+++ b/modules/filters/mod_deflate.c
@@ -426,6 +426,8 @@ static apr_status_t deflate_out_filter(ap_filter_t *f,
request_rec *r = f->r;
deflate_ctx *ctx = f->ctx;
int zRC;
+ apr_size_t len;
+ const char *data;
deflate_filter_config *c;
/* Do nothing if asked to filter nothing. */
@@ -446,6 +448,28 @@ static apr_status_t deflate_out_filter(ap_filter_t *f,
char *token;
const char *encoding;
+ /* Delay initialization until we have seen some data */
+ e = APR_BRIGADE_FIRST(bb);
+ while (1) {
+ apr_status_t rc;
+ if (e == APR_BRIGADE_SENTINEL(bb))
+ return ap_pass_brigade(f->next, bb);
+ if (APR_BUCKET_IS_EOS(e)) {
+ ap_remove_output_filter(f);
+ return ap_pass_brigade(f->next, bb);
+ }
+ if (APR_BUCKET_IS_METADATA(e))
+ continue;
+
+ rc = apr_bucket_read(e, &data, &len, APR_BLOCK_READ);
+ if (rc != APR_SUCCESS)
+ return rc;
+ if (len > 0)
+ break;
+
+ e = APR_BUCKET_NEXT(e);
+ }
+
ctx = f->ctx = apr_pcalloc(r->pool, sizeof(*ctx));
/*
@@ -645,9 +669,7 @@ static apr_status_t deflate_out_filter(ap_filter_t *f,
while (!APR_BRIGADE_EMPTY(bb))
{
- const char *data;
apr_bucket *b;
- apr_size_t len;
/*
* Optimization: If we are a HEAD request and bytes_sent is not zero