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
Index: buckets/deflate_buckets.c
===================================================================
--- buckets/deflate_buckets.c   (revision 1757569)
+++ buckets/deflate_buckets.c   (working copy)
@@ -503,7 +503,7 @@ static apr_status_t serf_deflate_wait_for_data(ser
               break;
             }
         case STATE_COMPRESS_INIT:
-            zRC = deflateInit2(&ctx->zstream, Z_DEFAULT_STRATEGY, Z_DEFLATED,
+            zRC = deflateInit2(&ctx->zstream, Z_DEFAULT_COMPRESSION, 
Z_DEFLATED,
                                ctx->windowSize, ctx->memLevel, 
Z_DEFAULT_STRATEGY);
             if (zRC != Z_OK) {
                 serf__log(LOGLVL_ERROR, LOGCOMP_COMPR, __FILE__, ctx->config,

Reply via email to