plugins.txt 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. ================
  2. Plugin Interface
  3. ================
  4. ------------
  5. Module: core
  6. ------------
  7. :Author: Jan Kneschke
  8. :Date: $Date: 2004/08/01 07:01:29 $
  9. :Revision: $Revision: 1.1 $
  10. :abstract:
  11. The plugin interface is an integral part of lighttpd which
  12. provides a flexible way to add specific functionality to lighttpd.
  13. .. meta::
  14. :keywords: lighttpd, plugins
  15. .. contents:: Table of Contents
  16. Description
  17. ===========
  18. Plugins allow you to enhance the functionality of lighttpd without
  19. changing the core of the webserver. They can be loaded at startup time
  20. and can change virtually any aspect of the behaviour of the webserver.
  21. Plugin Entry Points
  22. -------------------
  23. lighttpd has 16 hooks which are used in different states of the
  24. execution of the request:
  25. Serverwide hooks
  26. ````````````````
  27. :init_:
  28. called when the plugin is loaded
  29. :cleanup_:
  30. called when the plugin is unloaded
  31. :set_defaults_:
  32. called when the configuration has to be processed
  33. :handle_trigger_:
  34. called once a second
  35. :handle_sighup_:
  36. called when the server received a SIGHUP
  37. Connectionwide hooks
  38. ````````````````````
  39. Most of these hooks are called in ``http_response_prepare()`` after some
  40. fields in the connection structure are set.
  41. :handle_uri_raw_:
  42. called after uri.path_raw, uri.authority and uri.scheme are set
  43. :handle_uri_clean_:
  44. called after uri.path (a clean URI without .. and %20) is set
  45. :handle_docroot_:
  46. called at the end of the logical path handle to get a docroot
  47. :handle_subrequest_start_:
  48. called if the physical path is set up and checked
  49. :handle_subrequest_:
  50. called at the end of ``http_response_prepare()``
  51. :handle_physical_path_:
  52. called after the physical path is created and no other handler is
  53. found for this request
  54. :handle_request_done_:
  55. called when the request is done
  56. :handle_connection_close_:
  57. called if the connection has to be closed
  58. :handle_joblist_:
  59. called after the connection_state_engine is left again and plugin
  60. internal handles have to be called
  61. :connection_reset_:
  62. called if the connection structure has to be cleaned up
  63. Plugin Interface
  64. ----------------
  65. \*_plugin_init
  66. ``````````````
  67. Every plugin has a uniquely-named function which is called after the
  68. plugin is loaded. It is used to set up the ``plugin`` structure with
  69. some useful data:
  70. - name of the plugin ``name``
  71. - all hooks
  72. The field ``data`` and ``lib`` should not be touched in the init function.
  73. ``lib`` is the library handler from dlopen and ``data`` will be the storage
  74. of the internal plugin data.
  75. :returns:
  76. 0 (not handled)
  77. init
  78. ````
  79. The first real call of a plugin function is the init hook which is used
  80. to set up the internal plugin data. The internal plugin is assigned the
  81. ``data`` field mentioned in the \*_plugin_init description.
  82. :returns:
  83. a pointer to the internal plugin data.
  84. cleanup
  85. ```````
  86. The cleanup hook is called just before the plugin is unloaded. It is meant
  87. to free all buffers allocated in ``init`` or somewhere else in the plugin
  88. which are still not freed and to close all handles which were opened and
  89. are not closed yet.
  90. :returns:
  91. HANDLER_GO_ON if ok (not handled)
  92. set_defaults
  93. ````````````
  94. set_defaults is your entry point into the configfile parsing. It should
  95. pass a list of options to ``config_insert_values`` and check if
  96. the plugin configuration is valid. If it is not valid yet, it should
  97. set useful defaults or return with HANDLER_ERROR and an error message.
  98. :returns:
  99. HANDLER_GO_ON if ok
  100. HANDLER_ERROR will terminate lighttpd
  101. connection_reset
  102. ````````````````
  103. called at the end of each request
  104. :returns:
  105. HANDLER_GO_ON if ok
  106. HANDLER_ERROR on error
  107. handle_trigger
  108. ``````````````
  109. called once a second
  110. :returns:
  111. HANDLER_GO_ON if ok
  112. HANDLER_ERROR on error
  113. handle_sighup
  114. `````````````
  115. called if a SIGHUP is received (cycling logfiles, ...)
  116. :returns:
  117. HANDLER_GO_ON if ok
  118. HANDLER_ERROR on error
  119. handle_uri_raw
  120. ``````````````
  121. called after uri_raw is set
  122. :returns:
  123. HANDLER_GO_ON if ok
  124. HANDLER_FINISHED if the final output is prepared
  125. HANDLER_ERROR on error
  126. handle_uri_clean
  127. ````````````````
  128. called after uri.path is set
  129. :returns:
  130. HANDLER_GO_ON if ok
  131. HANDLER_FINISHED if the final output is prepared
  132. HANDLER_ERROR on error
  133. handle_docroot
  134. ``````````````
  135. called when a docroot is needed
  136. :returns:
  137. HANDLER_GO_ON if ok
  138. HANDLER_FINISHED if the final output is prepared
  139. HANDLER_ERROR on error
  140. handle_subrequest_start
  141. ```````````````````````
  142. called after physical.path is set
  143. :returns:
  144. HANDLER_GO_ON if ok
  145. HANDLER_FINISHED if the final output is prepared
  146. HANDLER_ERROR on error
  147. handle_subrequest
  148. `````````````````
  149. called if subrequest_start requested a COMEBACK or a WAIT_FOR_EVENT
  150. :returns:
  151. HANDLER_GO_ON if ok
  152. HANDLER_FINISHED if the final output is prepared
  153. HANDLER_ERROR on error
  154. handle_physical_path
  155. ````````````````````
  156. called after physical.path is set
  157. :returns:
  158. HANDLER_GO_ON if ok
  159. HANDLER_FINISHED if the final output is prepared
  160. HANDLER_ERROR on error
  161. handle_request_done
  162. ```````````````````
  163. called at the end of the request (logging, statistics, ...)
  164. :returns:
  165. HANDLER_GO_ON if ok
  166. HANDLER_ERROR on error
  167. handle_connection_close
  168. ```````````````````````
  169. called if the connection is terminated
  170. :returns:
  171. HANDLER_GO_ON if ok
  172. HANDLER_ERROR on error
  173. handle_joblist
  174. ``````````````
  175. called if the state of the connection has changed
  176. :returns:
  177. HANDLER_GO_ON if ok
  178. HANDLER_ERROR on error