<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[Snooda]]></title> 
<link>http://www.snooda.com/index</link> 
<description><![CDATA[Snooda's Blog]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[Snooda]]></copyright>
<item>
<link>http://www.snooda.com/read/</link>
<title><![CDATA[lighttpd中handle_start_backend钩子（hook）函数的理解]]></title> 
<author>snooda &lt;admin@snooda.com&gt;</author>
<category><![CDATA[lighttpd]]></category>
<pubDate>Wed, 25 Apr 2012 11:59:50 +0000</pubDate> 
<guid>http://www.snooda.com/read/</guid> 
<description>
<![CDATA[ 
	&nbsp;&nbsp;&nbsp;&nbsp;之前按字面意思理解handle_start_backend是说连接后端服务端口（webserver，fastcgi等等），今天发现并非如此。<br/>&nbsp;&nbsp;&nbsp;&nbsp;这个hook是在CON_STATE_HANDLE_REQUEST_HEADER状态时，<br/>如果con->mode仍旧是DIRECT类型且con->physical.path为空，会先调用：<br/>plugins_call_handle_uri_raw<br/>plugins_call_handle_uri_clean<br/>plugins_call_handle_docroot<br/>plugins_call_handle_physical<br/><br/>如果con->mode还是DIRECT，那么会判断con->physical.path指定的文件是否存在，<br/>&nbsp;&nbsp;&nbsp;&nbsp;若存在，如果是软链但是con->conf.follow_symlink为0，那么403，如果是目录但请求url不是路径名，则301跳转到目录路径（在末尾加/）<br/>&nbsp;&nbsp;&nbsp;&nbsp;若无权限访问，返回403<br/>&nbsp;&nbsp;&nbsp;&nbsp;若找不到文件，返回404<br/>&nbsp;&nbsp;&nbsp;&nbsp;若ENOTDIR（对文件做了目录操作），则考虑path_info<br/>&nbsp;&nbsp;&nbsp;&nbsp;若EMFILE（进程句柄不足），则返回HANDLER_WAIT_FOR_FD<br/>&nbsp;&nbsp;&nbsp;&nbsp;若不是以上情况，打印错误日志，返回500<br/><br/><br/>如果con->physical.path存在且无错误发生，或为ENOTDIR，那么又判断了一次是否存在（这里代码设计比较恶心）<br/>&nbsp;&nbsp;&nbsp;&nbsp;如果是普通文件且没有软链问题，那么break出去执行plugins_call_handle_start_backend。<br/>&nbsp;&nbsp;&nbsp;&nbsp;反之则一直向上遍历，直到遍历到一个真实存在的文件，如果找不到，那么404，如果找到了，将pathinfo串放入con->request.pathinfo。然后截短con->uri.path。<br/><br/>然后才会去调用plugins_call_handle_start_backend。<br/>所以对于很多动态请求是不会调用plugins_call_handle_start_backend的。<br/><br/>这个钩子被mod_access调用用来实现deny_all功能。<br/>被mod_indexfile调用用来实现默认文件功能（请求/时映射到index.php等）<br/><br/>Tags - <a href="http://www.snooda.com/tags/handle_start_backend/" rel="tag">handle start backend</a>
]]>
</description>
</item><item>
<link>http://www.snooda.com/read/#blogcomment</link>
<title><![CDATA[[评论] lighttpd中handle_start_backend钩子（hook）函数的理解]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.snooda.com/read/#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>