如何在响应体上调用函数?

时间:2019-01-22 17:54:16

标签: c apache apr

我有一个用c写的httpd模块项目。需要使用请求数据和响应主体来调用特定功能。在请求数据中工作正常,但是,如何在响应主体中调用特定函数?

我的示例代码是:

int apache_on_request(request_rec *r)
{
    // ...
}

static void register_hooks(apr_pool_t *p)
{
    ap_hook_handler(
        apache_on_request,
        NULL,
        NULL,
        APR_HOOK_REALLY_FIRST
    );
}

module AP_MODULE_DECLARE_DATA mod_demo =
{
    STANDARD20_MODULE_STUFF,
    NULL, /* Per-directory configuration handler */
    NULL, /* Merge handler for per-directory configurations */
    NULL, /* Per-server configuration handler */
    NULL, /* Merge handler for per-server configurations */
    NULL, /* Any directives we may have for httpd */
    register_hooks /* Our hook registering function */
};

我尝试使用ap_register_output_filter,但从未在Web浏览器的httpd请求中调用它:

// https://ci.apache.org/projects/httpd/trunk/doxygen/group__APACHE__CORE__FILTER.html#ga6dc4721ae075c103a3f3a93775d139fa
// Response body
ap_register_output_filter(
    "apache_on_response_body", // name
    apache_on_response_body,   // filter_funct
    NULL,                      // filter_init
    AP_FTYPE_CONTENT_SET       // ftype
);

0 个答案:

没有答案