From 4a81e1bdd9a1a28a84c1c47bc0800f542136cb57 Mon Sep 17 00:00:00 2001 From: Ian Holsman Date: Wed, 5 Mar 2003 22:14:33 +0000 Subject: [PATCH] new directive 'compressionlevel' Default compression level now changed to Zlib's default (was 'best_speed') Obtained from: Stephen Pierzchala Michael Schroepl Reviewed by: Ian Holsman git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@98895 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES | 4 ++++ docs/manual/mod/mod_deflate.xml | 19 +++++++++++++++++++ modules/filters/mod_deflate.c | 24 +++++++++++++++++++++++- 3 files changed, 46 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 914326968c..91d22b4831 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,10 @@ Changes with Apache 2.1.0-dev [Remove entries to the current 2.0 section below, when backported] + *) you can now specify the compression level for mod_deflate. + [Ian Holsman, Stephen Pierzchala , + Michael Schroepl ] + *) Restore the ability of htdigest.exe to create files that contain more than one user. PR 12910. [André Malo] diff --git a/docs/manual/mod/mod_deflate.xml b/docs/manual/mod/mod_deflate.xml index a522d701c6..e462a878b1 100644 --- a/docs/manual/mod/mod_deflate.xml +++ b/docs/manual/mod/mod_deflate.xml @@ -272,6 +272,7 @@ client + DeflateMemLevel How much memory should be used by zlib for compression DeflateMemLevel value @@ -286,5 +287,23 @@ client + +CompressionLevel +How much compression do we apply to the output +CompressionLevelvalue +Zlib's default +server configvirtual host + + + +

The CompressionLevel directive specifies + what level of compression should be used, the higher the value, + the better the compression, but the more CPU time is required to + achieve this.

+

The value must between 1 (less compression) and 9 (more compression).

+
+
+ + diff --git a/modules/filters/mod_deflate.c b/modules/filters/mod_deflate.c index 404fe41015..c14b10fff8 100644 --- a/modules/filters/mod_deflate.c +++ b/modules/filters/mod_deflate.c @@ -128,6 +128,7 @@ typedef struct deflate_filter_config_t { int windowSize; int memlevel; + int compressionlevel; apr_size_t bufferSize; char *note_ratio_name; char *note_input_name; @@ -135,6 +136,7 @@ typedef struct deflate_filter_config_t } deflate_filter_config; /* windowsize is negative to suppress Zlib header */ +#define DEFAULT_COMPRESSION Z_DEFAULT_COMPRESSION #define DEFAULT_WINDOWSIZE -15 #define DEFAULT_MEMLEVEL 9 #define DEFAULT_BUFFERSIZE 8096 @@ -167,6 +169,7 @@ static void *create_deflate_server_config(apr_pool_t *p, server_rec *s) c->memlevel = DEFAULT_MEMLEVEL; c->windowSize = DEFAULT_WINDOWSIZE; c->bufferSize = DEFAULT_BUFFERSIZE; + c->compressionlevel = DEFAULT_COMPRESSION; return c; } @@ -245,6 +248,23 @@ static const char *deflate_set_memlevel(cmd_parms *cmd, void *dummy, return NULL; } +static const char *deflate_set_compressionlevel(cmd_parms *cmd, void *dummy, + const char *arg) +{ + deflate_filter_config *c = ap_get_module_config(cmd->server->module_config, + &deflate_module); + int i; + + i = atoi(arg); + + if (i < 1 || i > 9) + return "Compression Level must be between 1 and 9"; + + c->compressionlevel = i; + + return NULL; +} + /* magic header */ static char deflate_magic[2] = { '\037', '\213' }; @@ -354,7 +374,7 @@ static apr_status_t deflate_out_filter(ap_filter_t *f, ctx->bb = apr_brigade_create(r->pool, f->c->bucket_alloc); ctx->buffer = apr_palloc(r->pool, c->bufferSize); - zRC = deflateInit2(&ctx->stream, Z_BEST_SPEED, Z_DEFLATED, + zRC = deflateInit2(&ctx->stream, c->compressionlevel, Z_DEFLATED, c->windowSize, c->memlevel, Z_DEFAULT_STRATEGY); @@ -822,6 +842,8 @@ static const command_rec deflate_filter_cmds[] = { "Set the Deflate Buffer Size"), AP_INIT_TAKE1("DeflateMemLevel", deflate_set_memlevel, NULL, RSRC_CONF, "Set the Deflate Memory Level (1-9)"), + AP_INIT_TAKE1("CompressionLevel", deflate_set_compressionlevel, NULL, RSRC_CONF, + "Set the Deflate Compression Level (1-9)"), {NULL} }; -- 2.40.0