www-apache-bugdb mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul J Murphy <p...@murph.org>
Subject mod_expires/8388: ExpiresByType type wildcard support
Date Sat, 22 Sep 2001 15:48:22 GMT

>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 <apbugs@Apache.Org> 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!     ]
 
 


Mime
View raw message