diff options
author | Joe Orton <jorton@apache.org> | 2004-10-12 13:40:00 +0200 |
---|---|---|
committer | Joe Orton <jorton@apache.org> | 2004-10-12 13:40:00 +0200 |
commit | 549714b3d3cfa1603de05ee076282c40a5f6fe7d (patch) | |
tree | 92442f787b98ee2786105a36fd1f983651ee227b /modules | |
parent | Minor comment fixes, no code changes: (diff) | |
download | apache2-549714b3d3cfa1603de05ee076282c40a5f6fe7d.tar.xz apache2-549714b3d3cfa1603de05ee076282c40a5f6fe7d.zip |
* modules/filters/mod_deflate.c: Remove use of zutil.h (not installed
by zlib 1.2.1) and OS_CODE. (deflate_out_filter): Simplify to use an
immortal brigade for the gzip header.
PR: 28673
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@105410 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules')
-rw-r--r-- | modules/filters/mod_deflate.c | 85 |
1 files changed, 19 insertions, 66 deletions
diff --git a/modules/filters/mod_deflate.c b/modules/filters/mod_deflate.c index 4567b5cc96..5b16371b06 100644 --- a/modules/filters/mod_deflate.c +++ b/modules/filters/mod_deflate.c @@ -46,52 +46,6 @@ #include "zlib.h" -#ifdef HAVE_ZUTIL_H -#include "zutil.h" -#else -/* As part of the encoding process, we must send what our OS_CODE is - * (or so it seems based on what I can tell of how gzip encoding works). - * - * zutil.h is not always included with zlib distributions (it is a private - * header), so this is straight from zlib 1.1.3's zutil.h. - */ -#ifdef OS2 -#define OS_CODE 0x06 -#endif - -#ifdef WIN32 /* Window 95 & Windows NT */ -#define OS_CODE 0x0b -#endif - -#if defined(VAXC) || defined(VMS) -#define OS_CODE 0x02 -#endif - -#ifdef AMIGA -#define OS_CODE 0x01 -#endif - -#if defined(ATARI) || defined(atarist) -#define OS_CODE 0x05 -#endif - -#if defined(MACOS) || defined(TARGET_OS_MAC) -#define OS_CODE 0x07 -#endif - -#ifdef __50SERIES /* Prime/PRIMOS */ -#define OS_CODE 0x0F -#endif - -#ifdef TOPS20 -#define OS_CODE 0x0a -#endif - -#ifndef OS_CODE -#define OS_CODE 0x03 /* assume Unix */ -#endif -#endif - static const char deflateFilterName[] = "DEFLATE"; module AP_MODULE_DECLARE_DATA deflate_module; @@ -106,6 +60,21 @@ typedef struct deflate_filter_config_t char *note_output_name; } deflate_filter_config; +/* RFC 1952 Section 2.3 defines the gzip header: + * + * +---+---+---+---+---+---+---+---+---+---+ + * |ID1|ID2|CM |FLG| MTIME |XFL|OS | + * +---+---+---+---+---+---+---+---+---+---+ + */ +static const char gzip_header[10] = +{ '\037', '\213', Z_DEFLATED, 0, + 0, 0, 0, 0, /* mtime */ + 0, 0x03 /* Unix OS_CODE */ +}; + +/* magic header */ +static const char deflate_magic[2] = { '\037', '\213' }; + /* windowsize is negative to suppress Zlib header */ #define DEFAULT_COMPRESSION Z_DEFAULT_COMPRESSION #define DEFAULT_WINDOWSIZE -15 @@ -236,9 +205,6 @@ static const char *deflate_set_compressionlevel(cmd_parms *cmd, void *dummy, return NULL; } -/* magic header */ -static char deflate_magic[2] = { '\037', '\213' }; - typedef struct deflate_ctx_t { z_stream stream; @@ -269,7 +235,7 @@ static apr_status_t deflate_out_filter(ap_filter_t *f, * we're in better shape. */ if (!ctx) { - char *buf, *token; + char *token; const char *encoding; /* only work on main request/no subrequests */ @@ -419,22 +385,9 @@ static apr_status_t deflate_out_filter(ap_filter_t *f, return ap_pass_brigade(f->next, bb); } - /* RFC 1952 Section 2.3 dictates the gzip header: - * - * +---+---+---+---+---+---+---+---+---+---+ - * |ID1|ID2|CM |FLG| MTIME |XFL|OS | - * +---+---+---+---+---+---+---+---+---+---+ - * - * If we wish to populate in MTIME (as hinted in RFC 1952), do: - * putLong(date_array, apr_time_now() / APR_USEC_PER_SEC); - * where date_array is a char[4] and then print date_array in the - * MTIME position. WARNING: ENDIANNESS ISSUE HERE. - */ - buf = apr_psprintf(r->pool, "%c%c%c%c%c%c%c%c%c%c", deflate_magic[0], - deflate_magic[1], Z_DEFLATED, 0 /* flags */, - 0, 0, 0, 0 /* 4 chars for mtime */, - 0 /* xflags */, OS_CODE); - e = apr_bucket_pool_create(buf, 10, r->pool, f->c->bucket_alloc); + /* add immortal gzip header */ + e = apr_bucket_immortal_create(gzip_header, sizeof gzip_header, + f->c->bucket_alloc); APR_BRIGADE_INSERT_TAIL(ctx->bb, e); /* If the entire Content-Encoding is "identity", we can replace it. */ |