]> granicus.if.org Git - apache/commitdiff
mod_lua: Add a fixups hook that checks if the original request is intended for LuaMap...
authorDaniel Gruno <humbedooh@apache.org>
Wed, 12 Mar 2014 22:56:44 +0000 (22:56 +0000)
committerDaniel Gruno <humbedooh@apache.org>
Wed, 12 Mar 2014 22:56:44 +0000 (22:56 +0000)
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1576981 13f79535-47bb-0310-9956-ffa450edef68

modules/lua/mod_lua.c

index db1275a1b7f91f15782468f96c05fcb83faed0ab..b63c4c0f8ead560fe9b4278440f1582f414a4cd8 100644 (file)
@@ -734,6 +734,32 @@ static int lua_request_rec_hook_harness(request_rec *r, const char *name, int ap
 }
 
 
+/* Fix for making sure that LuaMapHandler works when FallbackResource is set */
+static int lua_map_handler_fixups(request_rec *r)
+{
+    /* If there is no handler set yet, this might be a LuaMapHandler request */
+    if (r->handler == NULL) {
+        int n = 0;
+        ap_regmatch_t match[10];
+        const ap_lua_dir_cfg *cfg = ap_get_module_config(r->per_dir_config,
+                                                     &lua_module);
+        for (n = 0; n < cfg->mapped_handlers->nelts; n++) {
+            ap_lua_mapped_handler_spec *hook_spec =
+            ((ap_lua_mapped_handler_spec **) cfg->mapped_handlers->elts)[n];
+
+            if (hook_spec == NULL) {
+                continue;
+            }
+            if (!ap_regexec(hook_spec->uri_pattern, r->uri, 10, match, 0)) {
+                r->handler = apr_pstrdup(r->pool, "lua-map-handler");
+                return OK;
+            }
+        }
+    }
+    return DECLINED;
+}
+
+
 static int lua_map_handler(request_rec *r)
 {
     int rc, n = 0;
@@ -2100,6 +2126,9 @@ static void lua_register_hooks(apr_pool_t *p)
     APR_OPTIONAL_HOOK(ap_lua, lua_request, lua_request_hook, NULL, NULL,
                       APR_HOOK_REALLY_FIRST);
     ap_hook_handler(lua_map_handler, NULL, NULL, AP_LUA_HOOK_FIRST);
+    
+    /* Hook this right before FallbackResource kicks in */
+    ap_hook_fixups(lua_map_handler_fixups, NULL, NULL, AP_LUA_HOOK_LAST-2);
 #if APR_HAS_THREADS
     ap_hook_child_init(ap_lua_init_mutex, NULL, NULL, APR_HOOK_MIDDLE);
 #endif