Return-Path: Delivered-To: apmail-apache-bugdb-archive@apache.org Received: (qmail 24308 invoked by uid 500); 22 Sep 2001 15:50:01 -0000 Mailing-List: contact apache-bugdb-help@apache.org; run by ezmlm Precedence: bulk Reply-To: apache-bugdb@apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list apache-bugdb@apache.org Received: (qmail 24291 invoked by uid 501); 22 Sep 2001 15:50:01 -0000 Resent-Date: 22 Sep 2001 15:50:01 -0000 Resent-Message-ID: <20010922155001.24289.qmail@apache.org> Resent-From: submit@bugz.apache.org (GNATS Filer) Resent-To: apache-bugdb@apache.org Resent-Cc: apache-bugdb@apache.org Resent-Reply-To: submit@bugz.apache.org, paul@murph.org Received: (qmail 23814 invoked by uid 501); 22 Sep 2001 15:48:22 -0000 Message-Id: <20010922154822.23813.qmail@apache.org> Date: 22 Sep 2001 15:48:22 -0000 From: Paul J Murphy Reply-To: paul@murph.org To: submit@bugz.apache.org X-Send-Pr-Version: 3.110 Subject: mod_expires/8388: ExpiresByType type wildcard support >Number: 8388 >Category: mod_expires >Synopsis: ExpiresByType type wildcard support >Confidential: no >Severity: non-critical >Priority: medium >Responsible: apache >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: apache >Arrival-Date: Sat Sep 22 08:50:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: paul@murph.org >Release: 1.3.20 >Organization: apache >Environment: All Tested on Solaris 2.6 with gcc >Description: It would be quite useful to be able to use configuration similar to the following: ExpiresActive On ExpiresDefault A3600 ExpiresByType text/* A600 ExpiresByType image/* A604800 As of Apache/1.3.20, wildcards are not supported by the ExpiresByType directive, so you have to repeat the directive for each MIME sub-type that is of interest. >How-To-Repeat: Just try using wildcards with ExpiresByType - it doesn't work. >Fix: The following patch adds wildcard matching support to the tables code, the uses it in mod_expires. This has been tested, and seems to work just fine on Solaris 2.6. The new ap_table_match function is modelled on ap_table_get. diff -cr apache_1.3.20/src/include/ap_alloc.h apache_1.3.20-murph/src/include/ap_alloc.h *** apache_1.3.20/src/include/ap_alloc.h Sat Feb 3 20:14:49 2001 --- apache_1.3.20-murph/src/include/ap_alloc.h Sat Sep 22 14:26:04 2001 *************** *** 225,230 **** --- 225,231 ---- API_EXPORT(table *) ap_copy_table(pool *p, const table *); API_EXPORT(void) ap_clear_table(table *); API_EXPORT(const char *) ap_table_get(const table *, const char *); + API_EXPORT(const char *) ap_table_match(const table *, const char *); API_EXPORT(void) ap_table_set(table *, const char *name, const char *val); API_EXPORT(void) ap_table_setn(table *, const char *name, const char *val); API_EXPORT(void) ap_table_merge(table *, const char *name, const char *more_val); diff -cr apache_1.3.20/src/main/alloc.c apache_1.3.20-murph/src/main/alloc.c *** apache_1.3.20/src/main/alloc.c Mon Jan 15 17:04:55 2001 --- apache_1.3.20-murph/src/main/alloc.c Sat Sep 22 15:07:51 2001 *************** *** 1249,1254 **** --- 1249,1283 ---- return NULL; } + API_EXPORT(const char *) ap_table_match(const table *t, const char *key) + { + table_entry *elts = (table_entry *) t->a.elts; + int i, i_len, match, match_len; + + if (key == NULL) + return NULL; + + match_len = 0; + + for (i = 0; i < t->a.nelts; ++i) { + if (!strcasecmp(elts[i].key, key)) + return elts[i].val; + + if (!ap_strcasecmp_match(key, elts[i].key)) { + i_len = strlen(elts[i].key); + if (i_len > match_len) { + match = i; + match_len = i_len; + } + } + } + + if (match_len > 0) + return elts[match].val; + + return NULL; + } + API_EXPORT(void) ap_table_set(table *t, const char *key, const char *val) { register int i, j, k; diff -cr apache_1.3.20/src/modules/standard/mod_expires.c apache_1.3.20-murph/src/modules/standard/mod_expires.c *** apache_1.3.20/src/modules/standard/mod_expires.c Mon Jan 15 17:05:41 2001 --- apache_1.3.20-murph/src/modules/standard/mod_expires.c Sat Sep 22 14:01:44 2001 *************** *** 438,444 **** if (r->content_type == NULL) code = NULL; else ! code = (char *) ap_table_get(conf->expiresbytype, ap_field_noparam(r->pool, r->content_type)); if (code == NULL) { --- 438,444 ---- if (r->content_type == NULL) code = NULL; else ! code = (char *) ap_table_match(conf->expiresbytype, ap_field_noparam(r->pool, r->content_type)); if (code == NULL) { >Release-Note: >Audit-Trail: >Unformatted: [In order for any reply to be added to the PR database, you need] [to include in the Cc line and make sure the] [subject line starts with the report component and number, with ] [or without any 'Re:' prefixes (such as "general/1098:" or ] ["Re: general/1098:"). If the subject doesn't match this ] [pattern, your message will be misfiled and ignored. The ] ["apbugs" address is not added to the Cc line of messages from ] [the database automatically because of the potential for mail ] [loops. If you do not include this Cc, your reply may be ig- ] [nored unless you are responding to an explicit request from a ] [developer. Reply only with text; DO NOT SEND ATTACHMENTS! ]