httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Justin Erenkrantz <jerenkra...@apache.org>
Subject [PATCH] mod_mime and virtual requests
Date Wed, 04 Sep 2002 21:13:43 GMT
This patch does the following things:

- Morphs ap_run_sub_req-invoked handler's DONE to OK.
  (Fixes mod_dav always returning DONE and mod_include treating it
   as an error.)
- Adds 'ModMimeUsePathInfo' flag directive which tells mod_mime to
  use the full URI to do type lookups rather than r->filename.
- Allows mod_dav to be involved for subreqs.
- Switches mod_dav to use fixups for its handler config to allow
  mod_mime to run.

Any complaints before committing?  

I can now serve mod_include-based pages directly out of SVN.
Woo!  If PHP worked on non-file-backed data, it would work
too.  -- justin

Index: server/request.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/request.c,v
retrieving revision 1.114
diff -u -r1.114 request.c
--- server/request.c	17 May 2002 11:11:37 -0000	1.114
+++ server/request.c	4 Sep 2002 21:07:24 -0000
@@ -1867,6 +1867,9 @@
     }
     if (retval != OK) {
         retval = ap_invoke_handler(r);
+        if (retval == DONE) {
+            retval = OK;
+        }
     }
     ap_finalize_sub_req_protocol(r);
     return retval;
Index: modules/dav/main/mod_dav.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/dav/main/mod_dav.c,v
retrieving revision 1.84
diff -u -r1.84 mod_dav.c
--- modules/dav/main/mod_dav.c	3 Aug 2002 19:36:32 -0000	1.84
+++ modules/dav/main/mod_dav.c	4 Sep 2002 21:07:25 -0000
@@ -4429,8 +4429,8 @@
         return DECLINED;
     }
 
-    /* quickly ignore any HTTP/0.9 requests */
-    if (r->assbackwards) {
+    /* quickly ignore any HTTP/0.9 requests which aren't subreqs. */
+    if (r->assbackwards && !r->main) {
         return DECLINED;
     }
 
@@ -4595,7 +4595,7 @@
     return DECLINED;
 }
 
-static int dav_type_checker(request_rec *r)
+static int dav_fixups(request_rec *r)
 {
     dav_dir_conf *conf;
 
@@ -4635,8 +4635,6 @@
          * ### we lock down this hierarchy so that we are the ultimate
          * ### arbiter? (or do we simply depend on the administrator
          * ### to avoid conflicting configurations?)
-         *
-         * ### I think the OK stops running type-checkers. need to look.
          */
         r->handler = "dav-handler";
         return OK;
@@ -4649,7 +4647,7 @@
 {
     ap_hook_handler(dav_handler, NULL, NULL, APR_HOOK_MIDDLE);
     ap_hook_post_config(dav_init_handler, NULL, NULL, APR_HOOK_MIDDLE);
-    ap_hook_type_checker(dav_type_checker, NULL, NULL, APR_HOOK_FIRST);
+    ap_hook_fixups(dav_fixups, NULL, NULL, APR_HOOK_MIDDLE);
 
     dav_hook_find_liveprop(dav_core_find_liveprop, NULL, NULL, APR_HOOK_LAST);
     dav_hook_insert_all_liveprops(dav_core_insert_all_liveprops,
Index: modules/http/mod_mime.c
===================================================================
RCS file: /home/cvs/httpd-2.0/modules/http/mod_mime.c,v
retrieving revision 1.86
diff -u -r1.86 mod_mime.c
--- modules/http/mod_mime.c	18 May 2002 04:13:13 -0000	1.86
+++ modules/http/mod_mime.c	4 Sep 2002 21:07:25 -0000
@@ -127,6 +127,9 @@
     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.  Otherwise,
+                           * appned PATH_INFO to filename for lookups.
+                           */
 } mime_dir_config;
 
 typedef struct param_s {
@@ -162,6 +165,8 @@
 
     new->multimatch = MULTIMATCH_UNSET;
 
+    new->use_path_info = 0;
+
     return new;
 }
 /*
@@ -267,6 +272,9 @@
     new->multimatch = (add->multimatch != MULTIMATCH_UNSET) ?
         add->multimatch : base->multimatch;
 
+    new->use_path_info = add->use_path_info ?
+        add->use_path_info : base->use_path_info;
+
     return new;
 }
 
@@ -430,6 +438,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 +775,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 +787,17 @@
                                                    &mime_module);
     exception_list = apr_array_make(r->pool, 2, sizeof(char *));
 
+    if (!conf->use_path_info) {
+        resource_name = r->filename;
+    }
+    else {
+        resource_name = r->uri;
+    }
+
     /* 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;

Mime
View raw message