我是编写 apache 输出过滤器的新手,甚至更喜欢用 c 编写它们。我已经获取了一个示例过滤器(mod_substitute)源,并试图使其仅在请求针对特定主机时才起作用。出于我自己的原因,我需要将其作为编程功能而不是明智的配置。
我正在使用以下代码来试试这个:
request_rec *req = f->r;
ngf_module_ctx *ctx = f->ctx;
/* Test to see if this is a domain that needs optimization */
if (req->hostname != "localhost") {
ap_pass_brigade(f->next, bb);
return APR_SUCCESS;
}
使用调试打印我看到 req->hostname 值确实显示为 localhost,但是比较本身失败。
我究竟做错了什么 ?