坚信科学,分享技术

2018全新版本,未来在blog.54chen.com更新博客!

>>>尝试更加利于阅读的2014版科学院,以后都在新版上写。

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]
本文链接: http://www.54chen.com/_linux_/lighttpd-%e6%8f%92%e4%bb%b6%e5%bc%80%e5%8f%91%e6%96%b9%e6%b3%95.html

This entry was posted in linux and tagged , . Bookmark the permalink.

5 Responses to “Lighttpd 插件开发方法”

  1. 王艳秋 说:

    有没有一个实例代码可以学习学习

  2. daohua 说:

    精典 顶

  3. bjh 说:

    20.5万,金山软件Office插件开发大赛 任务悬赏金额:205000元 时间:79天 任务地址:http://www.zhubajie.com/task/iv/170046

  4. cc0cc 说:

    兄弟这广告发的。。。是金山的兄弟吗?

  5. 筱白 说:

    就看懂几个单词,其他不明白。。路过路过~~呼呼。。。

Leave a Reply