]> granicus.if.org Git - apache/commitdiff
Simplify mod_dav's handler.
authorGreg Stein <gstein@apache.org>
Fri, 6 Sep 2002 00:26:10 +0000 (00:26 +0000)
committerGreg Stein <gstein@apache.org>
Fri, 6 Sep 2002 00:26:10 +0000 (00:26 +0000)
The old mechanism would jam a handler name in whenever DAV was
configured for a directory. i.e. there weren't really any tests other
than "is DAV handling this directory?" The name was just a marker
which was tested later.

The new mechanism simplies performs the test right in the handler.
This is now possible since all handlers are called (before, you *had*
to set your own name so that your handler would be called). Since the
test is actually quite straightforward, we actually gain overall: no
more fixups hook, and a couple integer comparisons (rather than a
string compare).

And hoo... the code is simpler, too.

This code has been verified with "litmus 0.8", my own little
regression script, and some hand testing of static pages and CGIs. DAV
continues to work, and it doesn't appear that the changes interfered
with other operation.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@96658 13f79535-47bb-0310-9956-ffa450edef68

modules/dav/main/mod_dav.c

index a354eedc66168828872b48c5a5a3d774ecb35d77..8ccc22d0fe4c60e07f69192f4b8bb21db757abe2 100644 (file)
@@ -818,7 +818,7 @@ static int dav_method_get(request_rec *r)
     return DONE;
 }
 
-/* validate resource on POST, then pass it off to the default handler */
+/* validate resource/locks on POST, then pass to the default handler */
 static int dav_method_post(request_rec *r)
 {
     dav_resource *resource;
@@ -4423,21 +4423,45 @@ static int dav_method_bind(request_rec *r)
  */
 static int dav_handler(request_rec *r)
 {
-    dav_dir_conf *conf;
+    dav_dir_conf *conf = ap_get_module_config(r->per_dir_config, &dav_module);
 
-    if (strcmp(r->handler, "dav-handler")) {
+    /* if DAV is not enabled, then we've got nothing to do */
+    if (conf->provider == NULL) {
         return DECLINED;
     }
 
+    if (r->method_number == M_GET) {
+        /*
+         * ### need some work to pull Content-Type and Content-Language
+         * ### from the property database.
+         */
+
+        /*
+         * If the repository hasn't indicated that it will handle the
+         * GET method, then just punt.
+         *
+         * ### this isn't quite right... taking over the response can break
+         * ### things like mod_negotiation. need to look into this some more.
+         */
+        if (!conf->provider->repos->handle_get) {
+            return DECLINED;
+        }
+    }
+
+    /* ### do we need to do anything with r->proxyreq ?? */
+
     /* quickly ignore any HTTP/0.9 requests which aren't subreqs. */
     if (r->assbackwards && !r->main) {
         return DECLINED;
     }
 
-    /* ### do we need to do anything with r->proxyreq ?? */
-
-    conf = (dav_dir_conf *)ap_get_module_config(r->per_dir_config,
-                                                &dav_module);
+    /*
+     * ### anything else to do here? could another module and/or
+     * ### config option "take over" the handler here? i.e. how do
+     * ### we lock down this hierarchy so that we are the ultimate
+     * ### arbiter? (or do we simply depend on the administrator
+     * ### to avoid conflicting configurations?)
+     */
 
     /*
      * Set up the methods mask, since that's one of the reasons this handler
@@ -4486,8 +4510,6 @@ static int dav_handler(request_rec *r)
      * ### also, there is the issue with other methods (see ISSUES)
      */
 
-    /* ### more work necessary, now that we have M_foo for DAV methods */
-
     /* dispatch the appropriate method handler */
     if (r->method_number == M_GET) {
         return dav_method_get(r);
@@ -4581,6 +4603,7 @@ static int dav_handler(request_rec *r)
         return dav_method_merge(r);
     }
 
+    /* BIND method */
     if (r->method_number == dav_methods[DAV_M_BIND]) {
         return dav_method_bind(r);
     }
@@ -4595,59 +4618,10 @@ static int dav_handler(request_rec *r)
     return DECLINED;
 }
 
-static int dav_fixups(request_rec *r)
-{
-    dav_dir_conf *conf;
-
-    conf = (dav_dir_conf *)ap_get_module_config(r->per_dir_config,
-                                                &dav_module);
-
-    /* if DAV is not enabled, then we've got nothing to do */
-    if (conf->provider == NULL) {
-        return DECLINED;
-    }
-
-    if (r->method_number == M_GET) {
-        /*
-         * ### need some work to pull Content-Type and Content-Language
-         * ### from the property database.
-         */
-
-        /*
-         * If the repository hasn't indicated that it will handle the
-         * GET method, then just punt.
-         *
-         * ### this isn't quite right... taking over the response can break
-         * ### things like mod_negotiation. need to look into this some more.
-         */
-        if (!conf->provider->repos->handle_get) {
-            return DECLINED;
-        }
-    }
-
-    /* ### we should (instead) trap the ones that we DO understand */
-    /* ### the handler DOES handle POST, so we need to fix one of these */
-    if (r->method_number != M_POST) {
-
-        /*
-         * ### anything else to do here? could another module and/or
-         * ### config option "take over" the handler here? i.e. how do
-         * ### we lock down this hierarchy so that we are the ultimate
-         * ### arbiter? (or do we simply depend on the administrator
-         * ### to avoid conflicting configurations?)
-         */
-        r->handler = "dav-handler";
-        return OK;
-    }
-
-    return DECLINED;
-}
-
 static void register_hooks(apr_pool_t *p)
 {
     ap_hook_handler(dav_handler, NULL, NULL, APR_HOOK_MIDDLE);
     ap_hook_post_config(dav_init_handler, NULL, NULL, APR_HOOK_MIDDLE);
-    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,