瀏覽代碼

curl Adding docs on the curl_connect function

These docs needs to be extended, but it is a starting point
Olle E. Johansson 10 年之前
父節點
當前提交
dd19f2f6fe
共有 2 個文件被更改,包括 70 次插入14 次删除
  1. 36 6
      modules/curl/README
  2. 34 8
      modules/curl/doc/curl_admin.xml

+ 36 - 6
modules/curl/README

@@ -42,7 +42,11 @@ Carsten Bock
 
         4. Functions
 
-              4.1. curl_http_query(url, [post-data], result)
+              4.1. curl_connect(connection, url, result)
+                      curl_connect(connection, url, content_type, data,
+                      result)
+
+              4.2. curl_http_query(url, [post-data], result)
 
         5. Pseudovariables
 
@@ -68,7 +72,8 @@ Carsten Bock
    1.6. Set tlscacert parameter
    1.7. Set tlsverifyserver parameter
    1.8. Set curlcon parameter
-   1.9. curl_http_query() usage
+   1.9. curl_connect() usage
+   1.10. curl_http_query() usage
 
 Chapter 1. Admin Guide
 
@@ -93,7 +98,10 @@ Chapter 1. Admin Guide
 
    4. Functions
 
-        4.1. curl_http_query(url, [post-data], result)
+        4.1. curl_connect(connection, url, result)
+                curl_connect(connection, url, content_type, data, result)
+
+        4.2. curl_http_query(url, [post-data], result)
 
    5. Pseudovariables
 
@@ -275,9 +283,31 @@ timeout=12")
 
 4. Functions
 
-   4.1. curl_http_query(url, [post-data], result)
+   4.1. curl_connect(connection, url, result) curl_connect(connection,
+          url, content_type, data, result)
+
+   4.2. curl_http_query(url, [post-data], result)
+
+4.1. curl_connect(connection, url, result) curl_connect(connection, url,
+content_type, data, result)
+
+   Sends HTTP GET or POST request to a given connection. For a POST
+   request, content-type can be specified.
+
+   This function can be used from REQUEST_ROUTE, ONREPLY_ROUTE,
+   FAILURE_ROUTE, and BRANCH_ROUTE.
+
+   Example 1.9. curl_connect() usage
+...
+modparam("curl", "curlcon", "anders=>http://kamailio.org/api/");
+...
+# POST Request
+$var(res) = curl_connect("apiserver", "/postlåda", "application/json", "{ ok, {
+200, ok}}", "$avp(gurka)");
+xlog("L_INFO", "API-server Curl connection: $avp(gurka) Result $var(res)\n");
+...
 
-4.1. curl_http_query(url, [post-data], result)
+4.2. curl_http_query(url, [post-data], result)
 
    Sends HTTP GET or POST request according to URL given in "url"
    parameter, which is a string that may contain pseudo variables.
@@ -299,7 +329,7 @@ timeout=12")
    utils module. It is changed to use the same base library and settings
    as the rest of the functions in this module.
 
-   Example 1.9. curl_http_query() usage
+   Example 1.10. curl_http_query() usage
 ...
 # GET-Request
 curl_http_query("http://tutpro.com/index.php?r_uri=$(ru{s.escape.param})&f_uri=$

+ 34 - 8
modules/curl/doc/curl_admin.xml

@@ -62,7 +62,7 @@
 	
 	<section>
 		<title>Parameters</title>
-		<section id="utils.p.httpredirect">
+		<section id="curl.p.httpredirect">
 			<title><varname>httpredirect</varname> (int)</title>
 			<para>
 			If set to 1, enabled, CURL will follow HTTP 302 Redirects.
@@ -81,7 +81,7 @@ modparam("curl", "httpredirect", 0)
 				</programlisting>
 			</example>
 		</section>
-		<section id="utils.p.useragent">
+		<section id="curl.p.useragent">
 			<title><varname>useragent</varname> (string)</title>
 			<para>
 			Useragent to use in the HTTP protocol for requests. Defaults to
@@ -96,7 +96,7 @@ modparam("curl", "useragent", "Secret HTTP REST grabber 0.42")
 				</programlisting>
 			</example>
 		</section>
-		<section id="utils.p.connection_timeout">
+		<section id="curl.p.connection_timeout">
 			<title><varname>connection_timeout</varname> (int)</title>
 			<para>
 			Defines in seconds how long &kamailio; waits for response
@@ -117,7 +117,7 @@ modparam("curl", "connection_timeout", 2)
 				</programlisting>
 			</example>
 		</section>
-		<section id="utils.p.tlsclientcert">
+		<section id="curl.p.tlsclientcert">
 			<title><varname>tlsclientcert</varname> (string)</title>
 			<para>
 			File name for a TLS client certificate. The certificate needs to be encoded
@@ -140,7 +140,7 @@ modparam("curl", "tlsclientcert", "/var/certs/sollentuna.example.com.cert")
 				</programlisting>
 			</example>
 		</section>
-		<section id="utils.p.tlsclientkey">
+		<section id="curl.p.tlsclientkey">
 			<title><varname>tlsclientkey</varname> (string)</title>
 			<para>
 			File name for a TLS client key. The key needs to be encoded
@@ -163,7 +163,7 @@ modparam("curl", "tlsclientkey", "/var/certs/sollentuna.example.com.key")
 				</programlisting>
 			</example>
 		</section>
-		<section id="utils.p.tlscacert">
+		<section id="curl.p.tlscacert">
 			<title><varname>tlscacert</varname> (string)</title>
 			<para>
 			File name for the trusted TLS CA cert used to verify servers.
@@ -187,7 +187,7 @@ modparam("curl", "tlscacert", "/var/certs/ca/edvina-sip-ca.pem")
 				</programlisting>
 			</example>
 		</section>
-		<section id="utils.p.tlsverifyserver">
+		<section id="curl.p.tlsverifyserver">
 			<title><varname>tlsverifyserver</varname> (int)</title>
 			<para>
 			If set to 0, TLS verification of the server certificate
@@ -212,7 +212,7 @@ modparam("curl", "tlsverifyserver", 1)
 				</programlisting>
 			</example>
 		</section>
-		<section id="utils.p.curlcon">
+		<section id="curl.p.curlcon">
 			<title><varname>curlcon</varname> (string)</title>
 			<para>
 			Defines a connection and credentials for the connection for use
@@ -264,6 +264,32 @@ modparam("curl", "curlcon", "apifour=>http://stockholm.example.com/api/getstuff;
 
 	<section>
 	<title>Functions</title>
+		<section id="curl.f.curl_connect">
+			<title>
+				<function moreinfo="none">curl_connect(connection, url, result)</function>
+				<function moreinfo="none">curl_connect(connection, url, content_type, data, result)</function>
+			</title>
+			<para>
+				Sends HTTP GET or POST request to a given connection. For a
+				POST request, content-type can be specified.
+	    	        </para>
+			<para>
+			This function can be used from REQUEST_ROUTE,
+			ONREPLY_ROUTE, FAILURE_ROUTE, and BRANCH_ROUTE.
+			</para>
+			<example>
+				<title><function>curl_connect()</function> usage</title>
+				<programlisting format="linespecific">
+...
+modparam("curl", "curlcon", "anders=>http://kamailio.org/api/");
+...
+# POST Request
+$var(res) = curl_connect("apiserver", "/postlåda", "application/json", "{ ok, {200, ok}}", "$avp(gurka)");
+xlog("L_INFO", "API-server Curl connection: $avp(gurka) Result $var(res)\n");
+...
+				</programlisting>
+			</example>
+		</section>
 		<section id="curl.f.curl_http_query">
 			<title>
 				<function moreinfo="none">curl_http_query(url, [post-data], result)</function>