首页|五四陈后院|百丁屋论坛 CNFLEX组织|md5破解|关于|Profile
  • 802.1x代码 | bbsdown代码 | php手册 | 技术资料翻译

    Lighttpd 插件开发方法

    字号:T|T

     [文章作者:陈臻 本文版本: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/cc/lighttpd-%e6%8f%92%e4%bb%b6%e5%bc%80%e5%8f%91%e6%96%b9%e6%b3%95.html

    相关阅读:

    分类: c/c++, linux   Tags: ,

    [五四陈科学院出品]

    网友评论:

      5条评论

      • At 2009.02.12 18:56, 王艳秋 said:

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

        • At 2009.02.13 16:33, daohua said:

          精典 顶

          • At 2009.12.11 15:24, bjh said:

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

            • At 2009.12.11 16:34, cc0cc said:

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

            • At 2009.12.14 17:37, 筱白 said:

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

              (Required)
              (Required, will not be published)

            推广信息