From: Paul J. Reder Date: Tue, 3 Feb 2004 21:51:38 +0000 (+0000) Subject: *) Add support for IMT minor-type wildcards (e.g., text/*) to ExpiresByType. PR... X-Git-Tag: 2.0.49~164 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5e2901e845c1eb132cc547dbf528aa1dc8f059ac;p=thirdparty%2Fapache%2Fhttpd.git *) Add support for IMT minor-type wildcards (e.g., text/*) to ExpiresByType. PR#7991 Submitted by: Ken Coar Reviewed By: ken, stoddard, rederpj git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/APACHE_2_0_BRANCH@102492 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index b6c2aeb2d9e..e848b97f4eb 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,8 @@ Changes with Apache 2.0.49 + *) Add support for IMT minor-type wildcards (e.g., text/*) to + ExpiresByType. PR#7991 [Ken Coar] + *) Fix segfault in mod_mem_cache cache_insert() due to cache size becoming negative. PR: 21285, 21287 [Bill Stoddard, Massimo Torquati, Jean-Jacques Clar] diff --git a/STATUS b/STATUS index 438db870502..cbd03331180 100644 --- a/STATUS +++ b/STATUS @@ -1,5 +1,5 @@ APACHE 2.0 STATUS: -*-text-*- -Last modified at [$Date: 2004/02/03 15:30:57 $] +Last modified at [$Date: 2004/02/03 21:51:38 $] Release: @@ -160,10 +160,6 @@ PATCHES TO BACKPORT FROM 2.1 shows breakage on Solaris which can't -lcrypto -lssl without the extra pkgconfig/openssl.pc Libs: * foo } - * Backport wildcard ExpiresByType patch - modules/metadata/mod_expires.c r1.45 - +1: ken, stoddard, rederpj - * PREREQ for another fix (stranded piped logger processes) - ap_mpm_query(AP_MPMQ_MPM_STATE) No updates are available at present for the BeOS or OS/2 MPMs, diff --git a/modules/metadata/mod_expires.c b/modules/metadata/mod_expires.c index b2d31569bd0..be1b647a4bb 100644 --- a/modules/metadata/mod_expires.c +++ b/modules/metadata/mod_expires.c @@ -209,6 +209,7 @@ typedef struct { int active; + int wildcards; char *expiresdefault; apr_table_t *expiresbytype; } expires_dir_config; @@ -228,6 +229,7 @@ static void *create_dir_expires_config(apr_pool_t *p, char *dummy) expires_dir_config *new = (expires_dir_config *) apr_pcalloc(p, sizeof(expires_dir_config)); new->active = ACTIVE_DONTCARE; + new->wildcards = 0; new->expiresdefault = NULL; new->expiresbytype = apr_table_make(p, 4); return (void *) new; @@ -358,7 +360,13 @@ static const char *set_expiresbytype(cmd_parms *cmd, void *in_dir_config, { expires_dir_config *dir_config = in_dir_config; char *response, *real_code; + char *check; + check = strrchr(mime, '/'); + if ((strlen(++check) == 1) && (*check == '*')) { + dir_config->wildcards = 1; + } + if ((response = check_code(cmd->pool, code, &real_code)) == NULL) { apr_table_setn(dir_config->expiresbytype, mime, real_code); return NULL; @@ -411,7 +419,7 @@ static void *merge_expires_dir_configs(apr_pool_t *p, void *basev, void *addv) else { new->expiresdefault = base->expiresdefault; } - + new->wildcards = add->wildcards; new->expiresbytype = apr_table_overlay(p, add->expiresbytype, base->expiresbytype); return new; @@ -509,8 +517,37 @@ static apr_status_t expires_filter(ap_filter_t *f, expiry = apr_table_get(conf->expiresbytype, ap_field_noparam(r->pool, r->content_type)); if (expiry == NULL) { - /* Use the ExpiresDefault directive */ - expiry = conf->expiresdefault; + int usedefault = 1; + /* + * See if we have a wildcard entry for the major type. + */ + if (conf->wildcards) { + char *checkmime; + char *spos; + checkmime = apr_pstrdup(r->pool, r->content_type); + spos = strchr(checkmime, '/'); + if (spos != NULL) { + /* + * Without a '/' character, nothing we have will match. + * However, we have one. + */ + if (strlen(++spos) > 0) { + *spos++ = '*'; + *spos = '\0'; + } + else { + checkmime = apr_pstrcat(r->pool, checkmime, "*", NULL); + } + expiry = apr_table_get(conf->expiresbytype, checkmime); + usedefault = (expiry == NULL); + } + } + if (usedefault) { + /* + * Use the ExpiresDefault directive + */ + expiry = conf->expiresdefault; + } } if (expiry != NULL) { set_expiration_fields(r, expiry, t);