浏览代码

xmlrpc doc: use set_reply_close()

Updated doc & examples to use set_reply_close() and
set_reply_no_connect() in the XMLRPC route instead of return -1.
(this allows using rpc async commands with the broken python
xmlrpclib).
Andrei Pelinescu-Onciul 16 年之前
父节点
当前提交
b2ba3a96b3
共有 3 个文件被更改,包括 33 次插入6 次删除
  1. 16 3
      modules_s/xmlrpc/README
  2. 6 0
      modules_s/xmlrpc/doc/functions.xml
  3. 11 3
      modules_s/xmlrpc/doc/xmlrpc.xml

+ 16 - 3
modules_s/xmlrpc/README

@@ -456,14 +456,21 @@ Content-Length: 276
    xmlrpclib with a Transport class that works.
 
    For the second solution (force closing tcp connections after answering)
-   the XMLRPC route should end with a return -1, exit -1 or drop -1.
+   the XMLRPC route should have a set_reply_close() command before
+   dispatch_rpc(). set_reply_no_connect() is also recommended (avoid
+   trying to open tcp connection to xmlrpc clients that closed it).
+   Alternatively ending the XMLRPC route with return -1, exit -1 or drop
+   -1 can also be used, but note that this will not work for async rpcs
+   (it will close the connection immeidately and not on the async
+   response).
 
    Example 1.
 route[XMLRPC]{
-        dispatch_rpc();
         # close connection only for xmlrpclib user agents
         if search("^User-Agent:.*xmlrpclib"))
-                return -1 ;
+                set_reply_close();
+        set_reply_no_connect(); # optional
+        dispatch_rpc();
 }
 
 1.4. Client Examples
@@ -543,6 +550,9 @@ modparam("xmlrpc", "autoconversion", 1)
 modparam("xmlrpc", "route", "XMLRPC");
 #...
 route[XMLRPC]{
+        if search("^User-Agent:.*xmlrpclib"))
+                set_reply_close();
+        set_reply_no_connect(); # optional
         dispatch_rpc();
 }
 
@@ -566,5 +576,8 @@ route[XMLRPC]{
                 xmlrpc_reply("400", "Unauthorized");
                 return;
         }
+        if search("^User-Agent:.*xmlrpclib"))
+                set_reply_close();
+        set_reply_no_connect(); # optional
         dispatch_rpc();
 }

+ 6 - 0
modules_s/xmlrpc/doc/functions.xml

@@ -43,6 +43,9 @@
 modparam("xmlrpc", "route", "XMLRPC");
 #...
 route[XMLRPC]{
+	if search("^User-Agent:.*xmlrpclib"))
+		set_reply_close();
+	set_reply_no_connect(); # optional
 	dispatch_rpc();
 }
 		</programlisting>
@@ -74,6 +77,9 @@ route[XMLRPC]{
 		xmlrpc_reply("400", "Unauthorized");
 		return;
 	}
+	if search("^User-Agent:.*xmlrpclib"))
+		set_reply_close();
+	set_reply_no_connect(); # optional
 	dispatch_rpc();
 }
 		</programlisting>

+ 11 - 3
modules_s/xmlrpc/doc/xmlrpc.xml

@@ -677,15 +677,23 @@ Content-Length: 276
 		</para>
 		<para>
 		For the second solution (force closing tcp connections after answering)
-		the XMLRPC route should end with a return -1, exit -1 or drop -1.
+		the XMLRPC route should have a <function>set_reply_close()</function>
+		command before <function>dispatch_rpc()</function>.
+		<function>set_reply_no_connect()</function> is also recommended
+		(avoid trying to open tcp connection to xmlrpc clients that closed it).
+		Alternatively ending the XMLRPC route with return -1, exit -1 or
+		drop -1 can also be used, but note that this will not work for 
+		async rpcs (it will close the connection immeidately and not on the
+		async response).
 		<example>
 		<programlisting>
 <![CDATA[
 route[XMLRPC]{
-	dispatch_rpc();
 	# close connection only for xmlrpclib user agents
 	if search("^User-Agent:.*xmlrpclib"))
-		return -1 ;
+		set_reply_close();
+	set_reply_no_connect(); # optional
+	dispatch_rpc();
 }
 ]]>
 		</programlisting>