lighttpd插件开发步骤(一)

转自: http://www.54chen.com/index.php?p=309 

lighttpd插件开发步骤

 

插件架构说明

  • lighttpd的状态:为了便于理解lighttpd插件开发,需要了解lighttpd server在处理请求响应消息的过程中的11种状态,在这些状态中有如下重要函数需要被调用。对于这些状态,有的请求可能都会涉及到,有些请求可能只会经过部分状态。
状态含义对应函数
connectwaiting for a connectionnothing
reqstartinit the read-idle timernothing
readread http-request-header from networkconnection_handle_read_state()
connection_handle_read()
reqendparse requesthttp_request_parse()
readpostread http-request-content from networkconnection_handle_read_state()
connection_handle_read()
handlereqhandle the request internally (might result in sub-requests)http_response_prepare()
respstartprepare response headerconnection_handle_write_prepare()
writewrite response-header + content to networkconnection_handle_write()
respendcleanup environment, log requestplugins_call_handle_request_done()
plugins_call_handle_connection_close()
connection_close() (if not keep-alive)
connection_reset()
errorreset connection (incl. close())plugins_call_handle_request_done()
plugins_call_handle_connection_close()
connection_reset()
closeclose 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
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值