You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@serf.apache.org by Evgeny Kotkov <ev...@visualsvn.com> on 2016/08/24 20:29:00 UTC

[PATCH] Fix default compression level in deflate compress buckets

Hi,

I noticed that deflate compress buckets use an inappropriate value as
the compression level for `deflateInit2()`.

Please see deflate_buckets.c:505:

    case STATE_COMPRESS_INIT:
        zRC = deflateInit2(&ctx->zstream, Z_DEFAULT_STRATEGY, Z_DEFLATED,
                           ctx->windowSize, ctx->memLevel, Z_DEFAULT_STRATEGY);

The code above passes Z_DEFAULT_STRATEGY (0) as the compression
level, and this entirely disables the compression.  I tend to think that
the intention here was to use Z_DEFAULT_COMPRESSION (-1).  Note that
the compress buckets are only available in trunk, and that they currently
aren't used anywhere except the tests.

Please see the attached patch.

Log message:
[[[
Fix default compression level in deflate compress buckets.

* buckets/deflate_buckets.c
  (serf_deflate_wait_for_data): Pass Z_DEFAULT_COMPRESSION instead
   of Z_DEFAULT_STRATEGY as the compression level to deflateInit2().

]]]


Regards,
Evgeny Kotkov

Re: [PATCH] Fix default compression level in deflate compress buckets

Posted by Daniel Shahaf <d....@daniel.shahaf.name>.
Evgeny Kotkov wrote on Wed, Aug 24, 2016 at 23:29:00 +0300:
> [[[
> * buckets/deflate_buckets.c
>   (serf_deflate_wait_for_data): Pass Z_DEFAULT_COMPRESSION instead
>    of Z_DEFAULT_STRATEGY as the compression level to deflateInit2().

Might be better to say the "why", not the "what":

    (serf_deflate_wait_for_data): Enable compression by default.

> +++ buckets/deflate_buckets.c	(working copy)
> @@ -503,7 +503,7 @@ static apr_status_t serf_deflate_wait_for_data(ser
> -            zRC = deflateInit2(&ctx->zstream, Z_DEFAULT_STRATEGY, Z_DEFLATED,
> +            zRC = deflateInit2(&ctx->zstream, Z_DEFAULT_COMPRESSION, Z_DEFLATED,

Cheers,

Daniel