Apache Module编程总结1

1. Apache 处理请求的8个阶段:

1)name translation phase:URI -> Filename translation

2)Auth ID checking [is the user who they say they are?]

3)Auth access checking [is the user authorized here?]

4)Access checking other than auth

5)type-checking phase:Determining MIME type of the object requested

6)`Fixups' -- there aren't any of these yet, but the phase is intended as a hook for possible extensions like SetEnv, which don't really fit well elsewhere.

7)Actually sending a response back to the client.

8)Logging the request

2. Handler的唯一参数是request_rec,返回值是OK(成功处理这个请求),Declined(不关心这个请求)或者错误码(处理过程中遇到错误)

3. Directives

httpd.conf文件中有Directives,比如welcome hello。

然后在模块中的自己定义的cmd_rec my_cmds[]中,会把Directives对应的函数实现来关联。比如:

                 AP_INIT_TAKE1(“welcome”,

                set_modhello_string,

                NULL,

                RSRC_CONF,

                “hello,apache”),

这里还设定了这个Directives的作用域RSRC_conf,描述“hello, apache”

4.调试

可以通过ap_log_rerror(APLOG_MARK, APLOG_NOTICE, 0, r,"anti_spider: cookie data %s", param );来打印错误信息

也可以通过fprintf(stderr, "scanning #%s# from sohudb, size:%d/n", pConfig->conns[conn].key->data, pConfig->conns[conn].key->size);fflush(stderr);来打印错误信息。

这两种方式都是打印到/logs/error_log文件中

也可以通过gdb来调试,具体可以见这篇文章:

http://www.51testing.com/?13997/action_viewspace_itemid_5086.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值