From dd19f2f6fea6c9095baaaee3eda9f4aaf86127dc Mon Sep 17 00:00:00 2001 From: "Olle E. Johansson" Date: Sat, 19 Sep 2015 11:34:39 +0100 Subject: [PATCH] curl Adding docs on the curl_connect function These docs needs to be extended, but it is a starting point --- modules/curl/README | 42 ++++++++++++++++++++++++++++----- modules/curl/doc/curl_admin.xml | 42 ++++++++++++++++++++++++++------- 2 files changed, 70 insertions(+), 14 deletions(-) diff --git a/modules/curl/README b/modules/curl/README index e145e4ca3db..58cf21bb3b5 100644 --- a/modules/curl/README +++ b/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=$ diff --git a/modules/curl/doc/curl_admin.xml b/modules/curl/doc/curl_admin.xml index 49445d4ce56..ce3eba7af8d 100644 --- a/modules/curl/doc/curl_admin.xml +++ b/modules/curl/doc/curl_admin.xml @@ -62,7 +62,7 @@
Parameters -
+
<varname>httpredirect</varname> (int) If set to 1, enabled, CURL will follow HTTP 302 Redirects. @@ -81,7 +81,7 @@ modparam("curl", "httpredirect", 0)
-
+
<varname>useragent</varname> (string) Useragent to use in the HTTP protocol for requests. Defaults to @@ -96,7 +96,7 @@ modparam("curl", "useragent", "Secret HTTP REST grabber 0.42")
-
+
<varname>connection_timeout</varname> (int) Defines in seconds how long &kamailio; waits for response @@ -117,7 +117,7 @@ modparam("curl", "connection_timeout", 2)
-
+
<varname>tlsclientcert</varname> (string) 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")
-
+
<varname>tlsclientkey</varname> (string) 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")
-
+
<varname>tlscacert</varname> (string) 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")
-
+
<varname>tlsverifyserver</varname> (int) If set to 0, TLS verification of the server certificate @@ -212,7 +212,7 @@ modparam("curl", "tlsverifyserver", 1)
-
+
<varname>curlcon</varname> (string) Defines a connection and credentials for the connection for use @@ -264,6 +264,32 @@ modparam("curl", "curlcon", "apifour=>http://stockholm.example.com/api/getstuff;
Functions +
+ + <function moreinfo="none">curl_connect(connection, url, result)</function> + <function moreinfo="none">curl_connect(connection, url, content_type, data, result)</function> + + + 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. + + + <function>curl_connect()</function> 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"); +... + + +
<function moreinfo="none">curl_http_query(url, [post-data], result)</function>