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