summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2020-06-22 12:34:28 +0200
committerYann Ylavic <ylavic@apache.org>2020-06-22 12:34:28 +0200
commit3c47401358ce7ed0c72d5fcf08d8582533edf010 (patch)
tree492643aa7c30232eed89802718ca50b2f6364279 /modules
parentAdd pre_translate_name hook running before URI-path decoding. (diff)
downloadapache2-3c47401358ce7ed0c72d5fcf08d8582533edf010.tar.xz
apache2-3c47401358ce7ed0c72d5fcf08d8582533edf010.zip
Declare pre_translate hook in lua/info/log_debug/example modules, and docs.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1879077 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules')
-rw-r--r--modules/examples/mod_example_hooks.c17
-rw-r--r--modules/generators/mod_info.c1
-rw-r--r--modules/loggers/mod_log_debug.c8
-rw-r--r--modules/lua/mod_lua.c31
4 files changed, 57 insertions, 0 deletions
diff --git a/modules/examples/mod_example_hooks.c b/modules/examples/mod_example_hooks.c
index b6a12cb4b5..ec1df2b665 100644
--- a/modules/examples/mod_example_hooks.c
+++ b/modules/examples/mod_example_hooks.c
@@ -1176,6 +1176,22 @@ static int x_post_read_request(request_rec *r)
/*
* This routine gives our module an opportunity to translate the URI into an
+ * actual filename, before URL decoding happens.
+ *
+ * This is a RUN_FIRST hook.
+ */
+static int x_pre_translate_name(request_rec *r)
+{
+ /*
+ * We don't actually *do* anything here, except note the fact that we were
+ * called.
+ */
+ trace_request(r, "x_pre_translate_name()");
+ return DECLINED;
+}
+
+/*
+ * This routine gives our module an opportunity to translate the URI into an
* actual filename. If we don't do anything special, the server's default
* rules (Alias directives and the like) will continue to be followed.
*
@@ -1467,6 +1483,7 @@ static void x_register_hooks(apr_pool_t *p)
ap_hook_log_transaction(x_log_transaction, NULL, NULL, APR_HOOK_MIDDLE);
ap_hook_http_scheme(x_http_scheme, NULL, NULL, APR_HOOK_MIDDLE);
ap_hook_default_port(x_default_port, NULL, NULL, APR_HOOK_MIDDLE);
+ ap_hook_pre_translate_name(x_pre_translate_name, NULL, NULL, APR_HOOK_MIDDLE);
ap_hook_translate_name(x_translate_name, NULL, NULL, APR_HOOK_MIDDLE);
ap_hook_map_to_storage(x_map_to_storage, NULL,NULL, APR_HOOK_MIDDLE);
ap_hook_header_parser(x_header_parser, NULL, NULL, APR_HOOK_MIDDLE);
diff --git a/modules/generators/mod_info.c b/modules/generators/mod_info.c
index 1505b1a15d..90c84d03f2 100644
--- a/modules/generators/mod_info.c
+++ b/modules/generators/mod_info.c
@@ -322,6 +322,7 @@ static const hook_lookup_t request_hooks[] = {
{"HTTP Scheme", ap_hook_get_http_scheme},
{"Default Port", ap_hook_get_default_port},
{"Quick Handler", ap_hook_get_quick_handler},
+ {"Pre-Translate Name", ap_hook_get_pre_translate_name},
{"Translate Name", ap_hook_get_translate_name},
{"Map to Storage", ap_hook_get_map_to_storage},
{"Check Access", ap_hook_get_access_checker_ex},
diff --git a/modules/loggers/mod_log_debug.c b/modules/loggers/mod_log_debug.c
index 8a6c1244f5..3f27a958de 100644
--- a/modules/loggers/mod_log_debug.c
+++ b/modules/loggers/mod_log_debug.c
@@ -49,6 +49,7 @@ static const char * const hooks[] = {
"check_authn", /* 9 */
"check_authz", /* 10 */
"insert_filter", /* 11 */
+ "pre_translate_name", /* 12 */
NULL
};
@@ -109,6 +110,12 @@ static int log_debug_handler(request_rec *r)
return DECLINED;
}
+static int log_debug_pre_translate_name(request_rec *r)
+{
+ do_debug_log(r, hooks[12]);
+ return DECLINED;
+}
+
static int log_debug_translate_name(request_rec *r)
{
do_debug_log(r, hooks[3]);
@@ -263,6 +270,7 @@ static void register_hooks(apr_pool_t *p)
ap_hook_log_transaction(log_debug_log_transaction, NULL, NULL, APR_HOOK_FIRST);
ap_hook_quick_handler(log_debug_quick_handler, NULL, NULL, APR_HOOK_FIRST);
ap_hook_handler(log_debug_handler, NULL, NULL, APR_HOOK_FIRST);
+ ap_hook_pre_translate_name(log_debug_pre_translate_name, NULL, NULL, APR_HOOK_FIRST);
ap_hook_translate_name(log_debug_translate_name, NULL, NULL, APR_HOOK_FIRST);
ap_hook_map_to_storage(log_debug_map_to_storage, NULL, NULL, APR_HOOK_FIRST);
ap_hook_fixups(log_debug_fixups, NULL, NULL, APR_HOOK_FIRST);
diff --git a/modules/lua/mod_lua.c b/modules/lua/mod_lua.c
index 05f1e449eb..c6790ac9df 100644
--- a/modules/lua/mod_lua.c
+++ b/modules/lua/mod_lua.c
@@ -1205,6 +1205,11 @@ static int lua_check_user_id_harness_last(request_rec *r)
}
*/
+static int lua_pre_trans_name_harness(request_rec *r)
+{
+ return lua_request_rec_hook_harness(r, "pre_translate_name", APR_HOOK_MIDDLE);
+}
+
static int lua_translate_name_harness_first(request_rec *r)
{
return lua_request_rec_hook_harness(r, "translate_name", AP_LUA_HOOK_FIRST);
@@ -1277,6 +1282,21 @@ static int lua_quick_harness(request_rec *r, int lookup)
return lua_request_rec_hook_harness(r, "quick", APR_HOOK_MIDDLE);
}
+static const char *register_pre_trans_name_hook(cmd_parms *cmd, void *_cfg,
+ const char *file,
+ const char *function)
+{
+ return register_named_file_function_hook("pre_translate_name", cmd, _cfg, file,
+ function, APR_HOOK_MIDDLE);
+}
+
+static const char *register_pre_trans_name_block(cmd_parms *cmd, void *_cfg,
+ const char *line)
+{
+ return register_named_block_function_hook("pre_translate_name", cmd, _cfg,
+ line);
+}
+
static const char *register_translate_name_hook(cmd_parms *cmd, void *_cfg,
const char *file,
const char *function,
@@ -1848,6 +1868,14 @@ command_rec lua_commands[] = {
AP_INIT_TAKE3("LuaAuthzProvider", register_authz_provider, NULL, RSRC_CONF|EXEC_ON_READ,
"Provide an authorization provider"),
+ AP_INIT_TAKE2("LuaHookPreTranslateName", register_pre_trans_name_hook, NULL,
+ OR_ALL,
+ "Provide a hook for the pre_translate name phase of request processing"),
+
+ AP_INIT_RAW_ARGS("<LuaHookPreTranslateName", register_pre_trans_name_block, NULL,
+ EXEC_ON_READ | OR_ALL,
+ "Provide a hook for the pre_translate name phase of request processing"),
+
AP_INIT_TAKE23("LuaHookTranslateName", register_translate_name_hook, NULL,
OR_ALL,
"Provide a hook for the translate name phase of request processing"),
@@ -2101,6 +2129,9 @@ static void lua_register_hooks(apr_pool_t *p)
APR_HOOK_MIDDLE);
/* http_request.h hooks */
+ ap_hook_pre_translate_name(lua_pre_trans_name_harness, NULL, NULL,
+ APR_HOOK_MIDDLE);
+
ap_hook_translate_name(lua_translate_name_harness_first, NULL, NULL,
AP_LUA_HOOK_FIRST);
ap_hook_translate_name(lua_translate_name_harness, NULL, NULL,