Lighttpd 插件开发方法

 [文章作者:陈臻 本文版本:v1.0 最后修改:2009.2.12 转载请注明原文链接:http://www.54chen.com/c/309]

lighttpd插件开发步骤

 

插件架构说明

  • lighttpd的状态:为了便于理解lighttpd插件开发,需要了解lighttpd server在处理请求响应消息的过程中的11种状态,在这些状态中有如下重要函数需要被调用。对于这些状态,有的请求可能都会涉及到,有些请求可能只会经过部分状态。
状态 含义 对应函数
connect waiting for a connection nothing
reqstart init the read-idle timer nothing
read read http-request-header from network connection_handle_read_state()
connection_handle_read()
reqend parse request http_request_parse()
readpost read http-request-content from network connection_handle_read_state()
connection_handle_read()
handlereq handle the request internally (might result in sub-requests) http_response_prepare()
respstart prepare response header connection_handle_write_prepare()
write write response-header + content to network connection_handle_write()
respend cleanup environment, log request plugins_call_handle_request_done()
plugins_call_handle_connection_close()
connection_close() (if not keep-alive)
connection_reset()
error reset connection (incl. close()) plugins_call_handle_request_done()
plugins_call_handle_connection_close()
connection_reset()
close close connection (handle lingering close) connection_close()
  • lighttpd的回调函数:lighttpd在不同的状态中共有16个回调函数.
    • Serverwide hooks
init_
  called when the plugin is loaded
cleanup_
  called when the plugin is unloaded
set_defaults_
  called when the configuration has to be processed
handle_trigger_
  called once a second
handle_sighup_
  called when the server received a SIGHUP
 
    • Connectionwide hooks
 
Most of these hooks are called in ``http_response_prepare()`` after some
fields in the connection structure are set.

handle_uri_raw_
called after uri.path_raw, uri.authority and uri.scheme are set
handle_uri_clean_
called after uri.path (a clean URI without .. and %20) is set
handle_docroot_
called at the end of the logical path handle to get a docroothandle_subrequest_start_
called if the physical path is set up and checked
handle_subrequest_
called at the end of ``http_response_prepare()``
handle_physical_path_
called after the physical path is created and no other handler is
found for this request
handle_request_done_
called when the request is done
handle_connection_close_
called if the connection has to be closed
handle_joblist_
called after the connection_state_engine is left again and plugin
internal handles have to be called
connection_reset_
called if the connection structure has to be cleaned up


原创文章如转载,请注明:转载自五四陈科学院[http://www.54chen.com]

捐款订阅54chen
捐赠说明

Comments