1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * Portions of this software are based upon public domain software
19 * (zlib functions gz_open and gzwrite)
23 * mod_deflate.c: Perform deflate transfer-encoding on the fly
25 * Written by Ian Holsman
30 #include "http_config.h"
32 #include "apr_strings.h"
33 #include "apr_general.h"
34 #include "util_filter.h"
35 #include "apr_buckets.h"
36 #include "http_request.h"
37 #define APR_WANT_STRFUNC
45 /* As part of the encoding process, we must send what our OS_CODE is
46 * (or so it seems based on what I can tell of how gzip encoding works).
48 * zutil.h is not always included with zlib distributions (it is a private
49 * header), so this is straight from zlib 1.1.3's zutil.h.
55 #ifdef WIN32 /* Window 95 & Windows NT */
59 #if defined(VAXC) || defined(VMS)
67 #if defined(ATARI) || defined(atarist)
71 #if defined(MACOS) || defined(TARGET_OS_MAC)
75 #ifdef __50SERIES /* Prime/PRIMOS */
84 #define OS_CODE 0x03 /* assume Unix */
88 static const char deflateFilterName[] = "DEFLATE";
89 module AP_MODULE_DECLARE_DATA deflate_module;
91 typedef struct deflate_filter_config_t
96 apr_size_t bufferSize;
97 char *note_ratio_name;
98 char *note_input_name;
99 char *note_output_name;
100 } deflate_filter_config;
102 /* windowsize is negative to suppress Zlib header */
103 #define DEFAULT_COMPRESSION Z_DEFAULT_COMPRESSION
104 #define DEFAULT_WINDOWSIZE -15
105 #define DEFAULT_MEMLEVEL 9
106 #define DEFAULT_BUFFERSIZE 8096
108 /* Outputs a long in LSB order to the given file
109 * only the bottom 4 bits are required for the deflate file format.
111 static void putLong(unsigned char *string, unsigned long x)
113 string[0] = (unsigned char)(x & 0xff);
114 string[1] = (unsigned char)((x & 0xff00) >> 8);
115 string[2] = (unsigned char)((x & 0xff0000) >> 16);
116 string[3] = (unsigned char)((x & 0xff000000) >> 24);
119 /* Inputs a string and returns a long.
121 static unsigned long getLong(unsigned char *string)
123 return ((unsigned long)string[0])
124 | (((unsigned long)string[1]) << 8)
125 | (((unsigned long)string[2]) << 16)
126 | (((unsigned long)string[3]) << 24);
129 static void *create_deflate_server_config(apr_pool_t *p, server_rec *s)
131 deflate_filter_config *c = apr_pcalloc(p, sizeof *c);
133 c->memlevel = DEFAULT_MEMLEVEL;
134 c->windowSize = DEFAULT_WINDOWSIZE;
135 c->bufferSize = DEFAULT_BUFFERSIZE;
136 c->compressionlevel = DEFAULT_COMPRESSION;
141 static const char *deflate_set_window_size(cmd_parms *cmd, void *dummy,
144 deflate_filter_config *c = ap_get_module_config(cmd->server->module_config,
151 return "DeflateWindowSize must be between 1 and 15";
153 c->windowSize = i * -1;
158 static const char *deflate_set_buffer_size(cmd_parms *cmd, void *dummy,
161 deflate_filter_config *c = ap_get_module_config(cmd->server->module_config,
166 return "DeflateBufferSize should be positive";
169 c->bufferSize = (apr_size_t)n;
173 static const char *deflate_set_note(cmd_parms *cmd, void *dummy,
174 const char *arg1, const char *arg2)
176 deflate_filter_config *c = ap_get_module_config(cmd->server->module_config,
180 c->note_ratio_name = apr_pstrdup(cmd->pool, arg1);
182 else if (!strcasecmp(arg1, "ratio")) {
183 c->note_ratio_name = apr_pstrdup(cmd->pool, arg2);
185 else if (!strcasecmp(arg1, "input")) {
186 c->note_input_name = apr_pstrdup(cmd->pool, arg2);
188 else if (!strcasecmp(arg1, "output")) {
189 c->note_output_name = apr_pstrdup(cmd->pool, arg2);
192 return apr_psprintf(cmd->pool, "Unknown note type %s", arg1);
198 static const char *deflate_set_memlevel(cmd_parms *cmd, void *dummy,
201 deflate_filter_config *c = ap_get_module_config(cmd->server->module_config,
208 return "DeflateMemLevel must be between 1 and 9";
215 static const char *deflate_set_compressionlevel(cmd_parms *cmd, void *dummy,
218 deflate_filter_config *c = ap_get_module_config(cmd->server->module_config,
225 return "Compression Level must be between 1 and 9";
227 c->compressionlevel = i;
233 static char deflate_magic[2] = { '\037', '\213' };
235 typedef struct deflate_ctx_t
238 unsigned char *buffer;
240 apr_bucket_brigade *bb, *proc_bb;
243 static apr_status_t deflate_out_filter(ap_filter_t *f,
244 apr_bucket_brigade *bb)
247 request_rec *r = f->r;
248 deflate_ctx *ctx = f->ctx;
250 deflate_filter_config *c = ap_get_module_config(r->server->module_config,
253 /* If we don't have a context, we need to ensure that it is okay to send
254 * the deflated content. If we have a context, that means we've done
255 * this before and we liked it.
256 * This could be not so nice if we always fail. But, if we succeed,
257 * we're in better shape.
261 const char *encoding, *accepts;
263 /* only work on main request/no subrequests */
265 ap_remove_output_filter(f);
266 return ap_pass_brigade(f->next, bb);
269 /* some browsers might have problems, so set no-gzip
270 * (with browsermatch) for them
272 if (apr_table_get(r->subprocess_env, "no-gzip")) {
273 ap_remove_output_filter(f);
274 return ap_pass_brigade(f->next, bb);
277 /* Some browsers might have problems with content types
278 * other than text/html, so set gzip-only-text/html
279 * (with browsermatch) for them
281 if (r->content_type == NULL
282 || strncmp(r->content_type, "text/html", 9)) {
283 const char *env_value = apr_table_get(r->subprocess_env,
284 "gzip-only-text/html");
285 if ( env_value && (strcmp(env_value,"1") == 0) ) {
286 ap_remove_output_filter(f);
287 return ap_pass_brigade(f->next, bb);
291 /* Let's see what our current Content-Encoding is.
292 * If it's already encoded, don't compress again.
293 * (We could, but let's not.)
295 encoding = apr_table_get(r->headers_out, "Content-Encoding");
299 err_enc = apr_table_get(r->err_headers_out, "Content-Encoding");
301 encoding = apr_pstrcat(r->pool, encoding, ",", err_enc, NULL);
305 encoding = apr_table_get(r->err_headers_out, "Content-Encoding");
308 if (r->content_encoding) {
309 encoding = encoding ? apr_pstrcat(r->pool, encoding, ",",
310 r->content_encoding, NULL)
311 : r->content_encoding;
315 const char *tmp = encoding;
317 token = ap_get_token(r->pool, &tmp, 0);
318 while (token && *token) {
319 /* stolen from mod_negotiation: */
320 if (strcmp(token, "identity") && strcmp(token, "7bit") &&
321 strcmp(token, "8bit") && strcmp(token, "binary")) {
323 ap_remove_output_filter(f);
324 return ap_pass_brigade(f->next, bb);
327 /* Otherwise, skip token */
331 token = (*tmp) ? ap_get_token(r->pool, &tmp, 0) : NULL;
335 /* Even if we don't accept this request based on it not having
336 * the Accept-Encoding, we need to note that we were looking
337 * for this header and downstream proxies should be aware of that.
339 apr_table_mergen(r->headers_out, "Vary", "Accept-Encoding");
341 /* if they don't have the line, then they can't play */
342 accepts = apr_table_get(r->headers_in, "Accept-Encoding");
343 if (accepts == NULL) {
344 ap_remove_output_filter(f);
345 return ap_pass_brigade(f->next, bb);
348 token = ap_get_token(r->pool, &accepts, 0);
349 while (token && token[0] && strcasecmp(token, "gzip")) {
350 /* skip parameters, XXX: ;q=foo evaluation? */
351 while (*accepts == ';') {
353 token = ap_get_token(r->pool, &accepts, 1);
356 /* retrieve next token */
357 if (*accepts == ',') {
360 token = (*accepts) ? ap_get_token(r->pool, &accepts, 0) : NULL;
363 /* No acceptable token found. */
364 if (token == NULL || token[0] == '\0') {
365 ap_remove_output_filter(f);
366 return ap_pass_brigade(f->next, bb);
369 /* We're cool with filtering this. */
370 ctx = f->ctx = apr_pcalloc(r->pool, sizeof(*ctx));
371 ctx->bb = apr_brigade_create(r->pool, f->c->bucket_alloc);
372 ctx->buffer = apr_palloc(r->pool, c->bufferSize);
374 zRC = deflateInit2(&ctx->stream, c->compressionlevel, Z_DEFLATED,
375 c->windowSize, c->memlevel,
380 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
381 "unable to init Zlib: "
382 "deflateInit2 returned %d: URL %s",
384 return ap_pass_brigade(f->next, bb);
387 /* RFC 1952 Section 2.3 dictates the gzip header:
389 * +---+---+---+---+---+---+---+---+---+---+
390 * |ID1|ID2|CM |FLG| MTIME |XFL|OS |
391 * +---+---+---+---+---+---+---+---+---+---+
393 * If we wish to populate in MTIME (as hinted in RFC 1952), do:
394 * putLong(date_array, apr_time_now() / APR_USEC_PER_SEC);
395 * where date_array is a char[4] and then print date_array in the
396 * MTIME position. WARNING: ENDIANNESS ISSUE HERE.
398 buf = apr_psprintf(r->pool, "%c%c%c%c%c%c%c%c%c%c", deflate_magic[0],
399 deflate_magic[1], Z_DEFLATED, 0 /* flags */,
400 0, 0, 0, 0 /* 4 chars for mtime */,
401 0 /* xflags */, OS_CODE);
402 e = apr_bucket_pool_create(buf, 10, r->pool, f->c->bucket_alloc);
403 APR_BRIGADE_INSERT_TAIL(ctx->bb, e);
405 /* If the entire Content-Encoding is "identity", we can replace it. */
406 if (!encoding || !strcasecmp(encoding, "identity")) {
407 apr_table_setn(r->headers_out, "Content-Encoding", "gzip");
410 apr_table_mergen(r->headers_out, "Content-Encoding", "gzip");
412 apr_table_unset(r->headers_out, "Content-Length");
414 /* initialize deflate output buffer */
415 ctx->stream.next_out = ctx->buffer;
416 ctx->stream.avail_out = c->bufferSize;
419 while (!APR_BRIGADE_EMPTY(bb))
426 e = APR_BRIGADE_FIRST(bb);
428 if (APR_BUCKET_IS_EOS(e)) {
430 unsigned int deflate_len;
432 ctx->stream.avail_in = 0; /* should be zero already anyway */
434 deflate_len = c->bufferSize - ctx->stream.avail_out;
436 if (deflate_len != 0) {
437 b = apr_bucket_heap_create((char *)ctx->buffer,
440 APR_BRIGADE_INSERT_TAIL(ctx->bb, b);
441 ctx->stream.next_out = ctx->buffer;
442 ctx->stream.avail_out = c->bufferSize;
449 zRC = deflate(&ctx->stream, Z_FINISH);
451 if (deflate_len == 0 && zRC == Z_BUF_ERROR) {
455 done = (ctx->stream.avail_out != 0 || zRC == Z_STREAM_END);
457 if (zRC != Z_OK && zRC != Z_STREAM_END) {
462 buf = apr_palloc(r->pool, 8);
463 putLong((unsigned char *)&buf[0], ctx->crc);
464 putLong((unsigned char *)&buf[4], ctx->stream.total_in);
466 b = apr_bucket_pool_create(buf, 8, r->pool, f->c->bucket_alloc);
467 APR_BRIGADE_INSERT_TAIL(ctx->bb, b);
468 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
469 "Zlib: Compressed %ld to %ld : URL %s",
470 ctx->stream.total_in, ctx->stream.total_out, r->uri);
472 /* leave notes for logging */
473 if (c->note_input_name) {
474 apr_table_setn(r->notes, c->note_input_name,
475 (ctx->stream.total_in > 0)
476 ? apr_off_t_toa(r->pool,
477 ctx->stream.total_in)
481 if (c->note_output_name) {
482 apr_table_setn(r->notes, c->note_output_name,
483 (ctx->stream.total_in > 0)
484 ? apr_off_t_toa(r->pool,
485 ctx->stream.total_out)
489 if (c->note_ratio_name) {
490 apr_table_setn(r->notes, c->note_ratio_name,
491 (ctx->stream.total_in > 0)
493 (int)(ctx->stream.total_out
495 / ctx->stream.total_in))
499 deflateEnd(&ctx->stream);
501 /* Remove EOS from the old list, and insert into the new. */
502 APR_BUCKET_REMOVE(e);
503 APR_BRIGADE_INSERT_TAIL(ctx->bb, e);
505 /* Okay, we've seen the EOS.
506 * Time to pass it along down the chain.
508 return ap_pass_brigade(f->next, ctx->bb);
511 if (APR_BUCKET_IS_FLUSH(e)) {
515 apr_bucket_delete(e);
517 if (ctx->stream.avail_in > 0) {
518 zRC = deflate(&(ctx->stream), Z_SYNC_FLUSH);
524 ctx->stream.next_out = ctx->buffer;
525 len = c->bufferSize - ctx->stream.avail_out;
527 b = apr_bucket_heap_create((char *)ctx->buffer, len,
528 NULL, f->c->bucket_alloc);
529 APR_BRIGADE_INSERT_TAIL(ctx->bb, b);
530 ctx->stream.avail_out = c->bufferSize;
532 bkt = apr_bucket_flush_create(f->c->bucket_alloc);
533 APR_BRIGADE_INSERT_TAIL(ctx->bb, bkt);
534 rv = ap_pass_brigade(f->next, ctx->bb);
535 if (rv != APR_SUCCESS) {
542 apr_bucket_read(e, &data, &len, APR_BLOCK_READ);
544 /* This crc32 function is from zlib. */
545 ctx->crc = crc32(ctx->crc, (const Bytef *)data, len);
548 ctx->stream.next_in = (unsigned char *)data; /* We just lost const-ness,
549 * but we'll just have to
551 ctx->stream.avail_in = len;
553 while (ctx->stream.avail_in != 0) {
554 if (ctx->stream.avail_out == 0) {
557 ctx->stream.next_out = ctx->buffer;
558 len = c->bufferSize - ctx->stream.avail_out;
560 b = apr_bucket_heap_create((char *)ctx->buffer, len,
561 NULL, f->c->bucket_alloc);
562 APR_BRIGADE_INSERT_TAIL(ctx->bb, b);
563 ctx->stream.avail_out = c->bufferSize;
564 /* Send what we have right now to the next filter. */
565 rv = ap_pass_brigade(f->next, ctx->bb);
566 if (rv != APR_SUCCESS) {
571 zRC = deflate(&(ctx->stream), Z_NO_FLUSH);
577 apr_bucket_delete(e);
580 apr_brigade_cleanup(bb);
584 /* This is the deflate input filter (inflates). */
585 static apr_status_t deflate_in_filter(ap_filter_t *f,
586 apr_bucket_brigade *bb,
587 ap_input_mode_t mode,
588 apr_read_type_e block,
592 request_rec *r = f->r;
593 deflate_ctx *ctx = f->ctx;
596 deflate_filter_config *c;
598 /* just get out of the way of things we don't want. */
599 if (mode != AP_MODE_READBYTES) {
600 return ap_get_brigade(f->next, bb, mode, block, readbytes);
603 c = ap_get_module_config(r->server->module_config, &deflate_module);
607 char *token, deflate_hdr[10];
608 const char *encoding;
611 /* only work on main request/no subrequests */
613 ap_remove_input_filter(f);
614 return ap_get_brigade(f->next, bb, mode, block, readbytes);
617 /* Let's see what our current Content-Encoding is.
618 * If gzip is present, don't gzip again. (We could, but let's not.)
620 encoding = apr_table_get(r->headers_in, "Content-Encoding");
622 const char *tmp = encoding;
624 token = ap_get_token(r->pool, &tmp, 0);
625 while (token && token[0]) {
626 if (!strcasecmp(token, "gzip")) {
630 /* Otherwise, skip token */
632 token = ap_get_token(r->pool, &tmp, 0);
637 ap_remove_input_filter(f);
638 return ap_get_brigade(f->next, bb, mode, block, readbytes);
641 f->ctx = ctx = apr_pcalloc(f->r->pool, sizeof(*ctx));
642 ctx->bb = apr_brigade_create(r->pool, f->c->bucket_alloc);
643 ctx->proc_bb = apr_brigade_create(r->pool, f->c->bucket_alloc);
644 ctx->buffer = apr_palloc(r->pool, c->bufferSize);
646 rv = ap_get_brigade(f->next, ctx->bb, AP_MODE_READBYTES, block, 10);
647 if (rv != APR_SUCCESS) {
652 rv = apr_brigade_flatten(ctx->bb, deflate_hdr, &len);
653 if (rv != APR_SUCCESS) {
657 /* We didn't get the magic bytes. */
659 deflate_hdr[0] != deflate_magic[0] ||
660 deflate_hdr[1] != deflate_magic[1]) {
664 /* We can't handle flags for now. */
665 if (deflate_hdr[3] != 0) {
669 zRC = inflateInit2(&ctx->stream, c->windowSize);
673 inflateEnd(&ctx->stream);
674 ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r,
675 "unable to init Zlib: "
676 "inflateInit2 returned %d: URL %s",
678 ap_remove_input_filter(f);
679 return ap_get_brigade(f->next, bb, mode, block, readbytes);
682 /* initialize deflate output buffer */
683 ctx->stream.next_out = ctx->buffer;
684 ctx->stream.avail_out = c->bufferSize;
686 apr_brigade_cleanup(ctx->bb);
689 if (APR_BRIGADE_EMPTY(ctx->proc_bb)) {
690 rv = ap_get_brigade(f->next, ctx->bb, mode, block, readbytes);
692 if (rv != APR_SUCCESS) {
693 /* What about APR_EAGAIN errors? */
694 inflateEnd(&ctx->stream);
698 APR_BRIGADE_FOREACH(bkt, ctx->bb) {
702 /* If we actually see the EOS, that means we screwed up! */
703 if (APR_BUCKET_IS_EOS(bkt)) {
704 inflateEnd(&ctx->stream);
708 if (APR_BUCKET_IS_FLUSH(bkt)) {
709 apr_bucket *tmp_heap;
710 zRC = inflate(&(ctx->stream), Z_SYNC_FLUSH);
712 inflateEnd(&ctx->stream);
716 ctx->stream.next_out = ctx->buffer;
717 len = c->bufferSize - ctx->stream.avail_out;
719 ctx->crc = crc32(ctx->crc, (const Bytef *)ctx->buffer, len);
720 tmp_heap = apr_bucket_heap_create((char *)ctx->buffer, len,
721 NULL, f->c->bucket_alloc);
722 APR_BRIGADE_INSERT_TAIL(ctx->proc_bb, tmp_heap);
723 ctx->stream.avail_out = c->bufferSize;
725 /* Move everything to the returning brigade. */
726 APR_BUCKET_REMOVE(bkt);
727 APR_BRIGADE_CONCAT(bb, ctx->bb);
732 apr_bucket_read(bkt, &data, &len, APR_BLOCK_READ);
734 /* pass through zlib inflate. */
735 ctx->stream.next_in = (unsigned char *)data;
736 ctx->stream.avail_in = len;
740 while (ctx->stream.avail_in != 0) {
741 if (ctx->stream.avail_out == 0) {
742 apr_bucket *tmp_heap;
743 ctx->stream.next_out = ctx->buffer;
744 len = c->bufferSize - ctx->stream.avail_out;
746 ctx->crc = crc32(ctx->crc, (const Bytef *)ctx->buffer, len);
747 tmp_heap = apr_bucket_heap_create((char *)ctx->buffer, len,
748 NULL, f->c->bucket_alloc);
749 APR_BRIGADE_INSERT_TAIL(ctx->proc_bb, tmp_heap);
750 ctx->stream.avail_out = c->bufferSize;
753 zRC = inflate(&ctx->stream, Z_NO_FLUSH);
755 if (zRC == Z_STREAM_END) {
760 inflateEnd(&ctx->stream);
764 if (zRC == Z_STREAM_END) {
765 apr_bucket *tmp_heap, *eos;
767 ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
768 "Zlib: Inflated %ld to %ld : URL %s",
769 ctx->stream.total_in, ctx->stream.total_out,
772 len = c->bufferSize - ctx->stream.avail_out;
774 ctx->crc = crc32(ctx->crc, (const Bytef *)ctx->buffer, len);
775 tmp_heap = apr_bucket_heap_create((char *)ctx->buffer, len,
776 NULL, f->c->bucket_alloc);
777 APR_BRIGADE_INSERT_TAIL(ctx->proc_bb, tmp_heap);
778 ctx->stream.avail_out = c->bufferSize;
780 /* Is the remaining 8 bytes already in the avail stream? */
781 if (ctx->stream.avail_in >= 8) {
782 unsigned long compCRC, compLen;
783 compCRC = getLong(ctx->stream.next_in);
784 if (ctx->crc != compCRC) {
785 inflateEnd(&ctx->stream);
788 ctx->stream.next_in += 4;
789 compLen = getLong(ctx->stream.next_in);
790 if (ctx->stream.total_out != compLen) {
791 inflateEnd(&ctx->stream);
796 /* FIXME: We need to grab the 8 verification bytes
798 inflateEnd(&ctx->stream);
802 inflateEnd(&ctx->stream);
804 eos = apr_bucket_eos_create(f->c->bucket_alloc);
805 APR_BRIGADE_INSERT_TAIL(ctx->proc_bb, eos);
810 apr_brigade_cleanup(ctx->bb);
813 /* If we are about to return nothing for a 'blocking' read and we have
814 * some data in our zlib buffer, flush it out so we can return something.
816 if (block == APR_BLOCK_READ &&
817 APR_BRIGADE_EMPTY(ctx->proc_bb) &&
818 ctx->stream.avail_out < c->bufferSize) {
819 apr_bucket *tmp_heap;
821 ctx->stream.next_out = ctx->buffer;
822 len = c->bufferSize - ctx->stream.avail_out;
824 ctx->crc = crc32(ctx->crc, (const Bytef *)ctx->buffer, len);
825 tmp_heap = apr_bucket_heap_create((char *)ctx->buffer, len,
826 NULL, f->c->bucket_alloc);
827 APR_BRIGADE_INSERT_TAIL(ctx->proc_bb, tmp_heap);
828 ctx->stream.avail_out = c->bufferSize;
831 if (!APR_BRIGADE_EMPTY(ctx->proc_bb)) {
832 apr_bucket_brigade *newbb;
834 /* May return APR_INCOMPLETE which is fine by us. */
835 apr_brigade_partition(ctx->proc_bb, readbytes, &bkt);
837 newbb = apr_brigade_split(ctx->proc_bb, bkt);
838 APR_BRIGADE_CONCAT(bb, ctx->proc_bb);
839 APR_BRIGADE_CONCAT(ctx->proc_bb, newbb);
845 static void register_hooks(apr_pool_t *p)
847 ap_register_output_filter(deflateFilterName, deflate_out_filter, NULL,
848 AP_FTYPE_CONTENT_SET);
849 ap_register_input_filter(deflateFilterName, deflate_in_filter, NULL,
850 AP_FTYPE_CONTENT_SET);
853 static const command_rec deflate_filter_cmds[] = {
854 AP_INIT_TAKE12("DeflateFilterNote", deflate_set_note, NULL, RSRC_CONF,
855 "Set a note to report on compression ratio"),
856 AP_INIT_TAKE1("DeflateWindowSize", deflate_set_window_size, NULL,
857 RSRC_CONF, "Set the Deflate window size (1-15)"),
858 AP_INIT_TAKE1("DeflateBufferSize", deflate_set_buffer_size, NULL, RSRC_CONF,
859 "Set the Deflate Buffer Size"),
860 AP_INIT_TAKE1("DeflateMemLevel", deflate_set_memlevel, NULL, RSRC_CONF,
861 "Set the Deflate Memory Level (1-9)"),
862 AP_INIT_TAKE1("DeflateCompressionLevel", deflate_set_compressionlevel, NULL, RSRC_CONF,
863 "Set the Deflate Compression Level (1-9)"),
867 module AP_MODULE_DECLARE_DATA deflate_module = {
868 STANDARD20_MODULE_STUFF,
869 NULL, /* dir config creater */
870 NULL, /* dir merger --- default is to override */
871 create_deflate_server_config, /* server config */
872 NULL, /* merge server config */
873 deflate_filter_cmds, /* command table */
874 register_hooks /* register hooks */