functions.xml 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  3. "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
  4. <section id="xmlrpc.functions" xmlns:xi="http://www.w3.org/2001/XInclude">
  5. <sectioninfo>
  6. <revhistory>
  7. <revision>
  8. <revnumber>$Revision$</revnumber>
  9. <date>$Date$</date>
  10. </revision>
  11. </revhistory>
  12. </sectioninfo>
  13. <title>Functions</title>
  14. <section id="xmlrpc.dispatch_rpc">
  15. <title>
  16. <function>dispatch_rpc()</function>
  17. </title>
  18. <para>
  19. This function processes an XMLRPC request, found in the body of
  20. the request.
  21. </para>
  22. <para>
  23. It should be used only in a route specified using the
  24. <varname>"route"</varname> module parameter or if the request method
  25. is GET or POST (using it for other request methods will not have
  26. adverse side-effects, but it will probably not work).
  27. </para>
  28. <para>
  29. dispatch_rpc() extracts the XML-RPC document from the body of the
  30. request to determine the name of the RPC method to be called and then
  31. it searches through the list of all the RPC functions to find a
  32. function with matching name. If such a function is found then
  33. dispatch_rpc() will pass control to the function to handle the
  34. request.
  35. </para>
  36. <example>
  37. <title><function>dispatch_rpc</function> usage</title>
  38. <programlisting>
  39. #...
  40. modparam("xmlrpc", "route", "XMLRPC");
  41. #...
  42. route[XMLRPC]{
  43. if search("^User-Agent:.*xmlrpclib"))
  44. set_reply_close();
  45. set_reply_no_connect(); # optional
  46. dispatch_rpc();
  47. }
  48. </programlisting>
  49. </example>
  50. </section>
  51. <section id="xmlrpc.xmlrpc_reply">
  52. <title>
  53. <function>xmlrpc_reply(code, reason)</function>
  54. </title>
  55. <para>
  56. This function can be called from the config script to directly
  57. generate an XML-RPC reply.
  58. </para>
  59. <example>
  60. <title><function>xmlrpc_reply</function> usage</title>
  61. <programlisting>
  62. #...
  63. modparam("xmlrpc", "route", "XMLRPC");
  64. #...
  65. route[XMLRPC]{
  66. # allow XMLRPC requests only on TLS and only if the client
  67. # certificate is valid
  68. if (proto!=TLS){
  69. xmlrpc_reply("400", "xmlrpc allowed only over TLS");
  70. return;
  71. }
  72. if (@tls.peer.verified!=""){
  73. xmlrpc_reply("400", "Unauthorized");
  74. return;
  75. }
  76. if search("^User-Agent:.*xmlrpclib"))
  77. set_reply_close();
  78. set_reply_no_connect(); # optional
  79. dispatch_rpc();
  80. }
  81. </programlisting>
  82. </example>
  83. </section>
  84. </section>