gpt4 book ai didi

apache - 确保两个 Apache Filter 的执行顺序

转载 作者:行者123 更新时间:2023-12-01 12:53:00 25 4
gpt4 key购买 nike

我需要确保我的自定义过滤器始终在mod_rewrite 之前执行。根据 Apache Tutor , 过滤器不以确定的顺序运行:

The request processing axis is straightforward: the phases happen strictly in order. But confusion arises in the data axis. For maximum efficiency, this is pipelined, so the content generator and filters do not run in a deterministic order. So, for example, you cannot in general set something in an input filter and expect it to apply in the generator or output filters.

如何保证两个过滤器的执行顺序,或者有可能吗?


更新:有人有 indicatedmod_info 以显示有关模块及其顺序的详细信息。

最佳答案

理解这一点的最好方法是查看 apache 源代码。 ap_hook_fixups 的 mod_proxy 和 mod_rewrite 用法是如何在特定模块之前或之后插入 Hook 的完美示例。

假设你想在 mod_rewrite 之前插入一个钩子(Hook),你可以这样做:

static int my_fixup(request_rec *r)
{
/* do something with request headers before it goes to the mod_rewrite */
return OK;
}

static void register_hooks(apr_pool_t *p) {
static const char * const aszSucc[] = {"mod_rewrite.c", NULL};
ap_hook_fixups(my_fixup, NULL, aszSucc, APR_HOOK_FIRST);
}

此外,您还可以查看 http://httpd.apache.org/docs/2.2/developer/hooks.html其他类型的钩子(Hook)页面,或更好地了解如何控制钩子(Hook)调用顺序。

关于apache - 确保两个 Apache Filter 的执行顺序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11097096/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com