You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by je...@apache.org on 2002/09/05 09:31:15 UTC

cvs commit: httpd-2.0/modules/http mod_mime.c

jerenkrantz    2002/09/05 00:31:14

  Modified:    .        CHANGES
               modules/http mod_mime.c
  Log:
  Add ModMimeUsePathInfo directive.
  
  This directive allows mod_mime to lookup extension information for content
  served via Location blocks so that content-type, filters, etc can be
  applied to non-file content.
  
  (I wouldn't be shocked if we end up changing the directive name.)
  
  Revision  Changes    Path
  1.914     +2 -0      httpd-2.0/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/CHANGES,v
  retrieving revision 1.913
  retrieving revision 1.914
  diff -u -u -r1.913 -r1.914
  --- CHANGES	4 Sep 2002 09:07:25 -0000	1.913
  +++ CHANGES	5 Sep 2002 07:31:13 -0000	1.914
  @@ -1,5 +1,7 @@
   Changes with Apache 2.0.41
   
  +  *) Add ModMimeUsePathInfo directive.  [Justin Erenkrantz]
  +
     *) mod_cache: added support for caching streamed responses (proxy,
        CGI, etc) with optional CacheMaxStreamingBuffer setting [Brian Pane]
   
  
  
  
  1.87      +29 -3     httpd-2.0/modules/http/mod_mime.c
  
  Index: mod_mime.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/http/mod_mime.c,v
  retrieving revision 1.86
  retrieving revision 1.87
  diff -u -u -r1.86 -r1.87
  --- mod_mime.c	18 May 2002 04:13:13 -0000	1.86
  +++ mod_mime.c	5 Sep 2002 07:31:14 -0000	1.87
  @@ -127,6 +127,12 @@
       int multimatch;       /* Extensions to include in multiview matching
                              * for filenames, e.g. Filters and Handlers 
                              */
  +    int use_path_info;    /* If set to 0, only use filename.
  +                           * If set to 1, append PATH_INFO to filename for
  +                           *   lookups.
  +                           * If set to 2, this value is unset and is
  +                           *   effectively 0.  
  +                           */
   } mime_dir_config;
   
   typedef struct param_s {
  @@ -162,6 +168,8 @@
   
       new->multimatch = MULTIMATCH_UNSET;
   
  +    new->use_path_info = 2;
  +
       return new;
   }
   /*
  @@ -267,6 +275,13 @@
       new->multimatch = (add->multimatch != MULTIMATCH_UNSET) ?
           add->multimatch : base->multimatch;
   
  +    if ((add->use_path_info & 2) == 0) {
  +        new->use_path_info = add->use_path_info;
  +    }
  +    else {
  +        new->use_path_info = base->use_path_info;
  +    }
  +
       return new;
   }
   
  @@ -430,6 +445,9 @@
           "one or more file extensions"),
       AP_INIT_TAKE1("TypesConfig", set_types_config, NULL, RSRC_CONF,
           "the MIME types config file"),
  +    AP_INIT_FLAG("ModMimeUsePathInfo", ap_set_flag_slot,
  +        (void *)APR_OFFSETOF(mime_dir_config, use_path_info), ACCESS_CONF,
  +        "Set to 'yes' to allow mod_mime to use path info for type checking"),
       {NULL}
   };
   
  @@ -764,7 +782,7 @@
       mime_dir_config *conf;
       apr_array_header_t *exception_list;
       char *ext;
  -    const char *fn, *type, *charset = NULL;
  +    const char *fn, *type, *charset = NULL, *resource_name;
       int found_metadata = 0;
   
       if (r->finfo.filetype == APR_DIR) {
  @@ -776,10 +794,18 @@
                                                      &mime_module);
       exception_list = apr_array_make(r->pool, 2, sizeof(char *));
   
  +    /* If use_path_info is explicitly set to on (value & 1 == 1), append. */
  +    if (conf->use_path_info & 1) {
  +        resource_name = apr_pstrcat(r->pool, r->filename, r->path_info, NULL);
  +    }
  +    else {
  +        resource_name = r->filename;
  +    }
  +
       /* Always drop the path leading up to the file name.
        */
  -    if ((fn = strrchr(r->filename, '/')) == NULL) {
  -        fn = r->filename;
  +    if ((fn = strrchr(resource_name, '/')) == NULL) {
  +        fn = resource_name;
       }
       else {
           ++fn;
  
  
  

Re: cvs commit: httpd-2.0/modules/http mod_mime.c

Posted by Justin Erenkrantz <je...@apache.org>.
On Thu, Sep 05, 2002 at 06:43:52AM -0700, Ian Holsman wrote:
> -1
> don't use magic numbers
> please use a #define

Sorry, but the rest of the server uses this strategy for flags.
Look specifically at IdentityCheck and ContentDigest.

The problem is that the AP_INIT_FLAG and ap_set_flag_slot passes
in 0, 1 and therefore that must correspond to Off and On.  Using a
local enum or a #define will break compatibility with how flags are
handled (because some genius may think they can change those values).
Therefore, I believe we have to stick with magic numbers.

And, due to directive inheritance, there is also needed a
special value for 'unset' - and the strategy we have used in
the past is to use 2.  

If you think it'd be better to rewrite all of the flag handling
code to use global enums, I'd agree, but I'm not going to do
that.  That will break all modules using flags.  -- justin

Re: cvs commit: httpd-2.0/modules/http mod_mime.c

Posted by gr...@apache.org.
Ian Holsman wrote:
> 
> jerenkrantz@apache.org wrote:
> 
> >jerenkrantz    2002/09/05 00:31:14
> >
> >  Modified:    .        CHANGES
> >               modules/http mod_mime.c
> >  Log:
> >  Add ModMimeUsePathInfo directive.
> >
> >  +    int use_path_info;    /* If set to 0, only use filename.
> >  +                           * If set to 1, append PATH_INFO to filename for
> >  +                           *   lookups.
> >  +                           * If set to 2, this value is unset and is
> >  +                           *   effectively 0.
> >  +                           */
> >
> -1
> don't use magic numbers
> please use a #define

better yet, an enum.

Greg

Re: cvs commit: httpd-2.0/modules/http mod_mime.c

Posted by Ian Holsman <Ia...@cnet.com>.
jerenkrantz@apache.org wrote:

>jerenkrantz    2002/09/05 00:31:14
>
>  Modified:    .        CHANGES
>               modules/http mod_mime.c
>  Log:
>  Add ModMimeUsePathInfo directive.
>  
>  +    int use_path_info;    /* If set to 0, only use filename.
>  +                           * If set to 1, append PATH_INFO to filename for
>  +                           *   lookups.
>  +                           * If set to 2, this value is unset and is
>  +                           *   effectively 0.  
>  +                           */
>
-1
don't use magic numbers
please use a #define

>   
>  +    new->use_path_info = 2;
>  +
>
>  
>



Re: cvs commit: httpd-2.0/modules/http mod_mime.c

Posted by Ian Holsman <Ia...@cnet.com>.
jerenkrantz@apache.org wrote:

>jerenkrantz    2002/09/05 00:31:14
>
>  Modified:    .        CHANGES
>               modules/http mod_mime.c
>  Log:
>  Add ModMimeUsePathInfo directive.
>  
>  +    int use_path_info;    /* If set to 0, only use filename.
>  +                           * If set to 1, append PATH_INFO to filename for
>  +                           *   lookups.
>  +                           * If set to 2, this value is unset and is
>  +                           *   effectively 0.  
>  +                           */
>
-1
don't use magic numbers
please use a #define

>   
>  +    new->use_path_info = 2;
>  +
>
>  
>