httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject cvs commit: httpd-2.0/modules/metadata mod_expires.c
Date Sun, 01 Jun 2003 15:10:31 GMT
coar        2003/06/01 08:10:30

  Modified:    .        CHANGES
               modules/metadata mod_expires.c
  Log:
  	Allow ExpiresByType to accept and understand minor-type wildcards
  	(e.g., text/*).  They'll be used if an exact type match isn't
  	found; if there's no wildcard match, the expiry falls back to any
  	ExpiresDefault setting as usual.
  
  PR:		7991
  
  Revision  Changes    Path
  1.1192    +3 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.1191
  retrieving revision 1.1192
  diff -u -u -r1.1191 -r1.1192
  --- CHANGES	31 May 2003 22:00:23 -0000	1.1191
  +++ CHANGES	1 Jun 2003 15:10:29 -0000	1.1192
  @@ -2,6 +2,9 @@
   
     [Remove entries to the current 2.0 section below, when backported]
   
  +  *) Add support for IMT minor-type wildcards (e.g., text/*) to
  +     ExpiresByType.  PR#7991  [Ken Coar]
  +
     *) Prevent the server from crashing when entering infinite loops. The
        new LimitInternalRecursion directive configures limits of subsequent
        internal redirects and nested subrequests, after which the request
  
  
  
  1.45      +40 -3     httpd-2.0/modules/metadata/mod_expires.c
  
  Index: mod_expires.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/metadata/mod_expires.c,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -u -r1.44 -r1.45
  --- mod_expires.c	31 May 2003 22:00:23 -0000	1.44
  +++ mod_expires.c	1 Jun 2003 15:10:30 -0000	1.45
  @@ -208,6 +208,7 @@
   
   typedef struct {
       int active;
  +    int wildcards;
       char *expiresdefault;
       apr_table_t *expiresbytype;
   } expires_dir_config;
  @@ -227,6 +228,7 @@
       expires_dir_config *new =
       (expires_dir_config *) apr_pcalloc(p, sizeof(expires_dir_config));
       new->active = ACTIVE_DONTCARE;
  +    new->wildcards = 0;
       new->expiresdefault = "";
       new->expiresbytype = apr_table_make(p, 4);
       return (void *) new;
  @@ -357,7 +359,13 @@
   {
       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;
  @@ -410,7 +418,7 @@
       else {
   	new->expiresdefault = base->expiresdefault;
       }
  -
  +    new->wildcards = add->wildcards;
       new->expiresbytype = apr_table_overlay(p, add->expiresbytype,
                                           base->expiresbytype);
       return new;
  @@ -508,8 +516,37 @@
           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);
  
  
  

Mime
View raw message