|
@@ -0,0 +1,71 @@
|
|
|
|
+
|
|
|
|
+# Test of the new http_client API module
|
|
|
|
+#
|
|
|
|
+# (C) 2016 Edvina AB, Sollentuna, Sweden. All rights reserved.
|
|
|
|
+#
|
|
|
|
+#
|
|
|
|
+
|
|
|
|
+debug=3
|
|
|
|
+log_stderror=yes
|
|
|
|
+fork=no
|
|
|
|
+
|
|
|
|
+# ------------------ module loading ----------------------------------
|
|
|
|
+# Set a path to known locations for modules
|
|
|
|
+#
|
|
|
|
+mpath="/usr/local/lib64/kamailio/modules:/usr/local/lib/kamailio/modules:/usr/lib64/kamailio/modules:/usr/lib/kamailio/modules"
|
|
|
|
+loadmodule "pv.so" # For pseudo-variable support in log messages etc
|
|
|
|
+loadmodule "xlog.so" # For extended logging with pseudovariables
|
|
|
|
+loadmodule "kex.so" # Kamailio extensions:
|
|
|
|
+ # Script flags and basic mi commands (version, pwd, get_statistics)
|
|
|
|
+#
|
|
|
|
+loadmodule "tm.so" # Transactions are needed in order to fork
|
|
|
|
+loadmodule "tmx.so" # Kamailio extras to TM
|
|
|
|
+#
|
|
|
|
+loadmodule "sl.so" # Stateless replies - needed by registrar.so
|
|
|
|
+loadmodule "rtimer.so" # For ticks
|
|
|
|
+loadmodule "htable.so" # For init event route
|
|
|
|
+loadmodule "http_client.so" # THe CURL module
|
|
|
|
+loadmodule "httpapitest.so" # THe CURL module
|
|
|
|
+loadmodule "cfgutils.so" # Memory debugging
|
|
|
|
+
|
|
|
|
+# main routing logic
|
|
|
|
+
|
|
|
|
+modparam("http_client", "connection_timeout", 42);
|
|
|
|
+modparam("http_client", "keep_connections", 1);
|
|
|
|
+modparam("http_client", "maxdatasize", 1000);
|
|
|
|
+modparam("http_client", "useragent", "Olle's Peace and Restful little HTTP grabber 42.3");
|
|
|
|
+#user and password
|
|
|
|
+modparam("http_client", "httpcon", "lisa=>https://www.kamailio.org/w/");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+# ------------------------- request routing logic -------------------
|
|
|
|
+route {
|
|
|
|
+ sl_send_reply(400, "Do not wake me up");
|
|
|
|
+ exit;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+onreply_route {
|
|
|
|
+ xlog("L_INFO", "<-- Incoming response: $rs $rr - from $si\n");
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+branch_route[BRANCH_ROUTE]
|
|
|
|
+{
|
|
|
|
+ xlog("L_INFO", " --> Outgoing branch $T_branch_idx : $rm from $si to $ru \n");
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+onsend_route
|
|
|
|
+{
|
|
|
|
+ xlog("ONSEND --> Sending from $sndfrom(proto):$sndfrom(ip):$sndfrom(port) to $sndto(proto):$sndto(ip):$sndto(port) \n");
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+# This route is executed at Kamailio start
|
|
|
|
+event_route[htable:mod-init]
|
|
|
|
+{
|
|
|
|
+ xlog("L_ERR", "### Kamailio starting $timef(HH:mm) \n");
|
|
|
|
+ $avp(gurka) = "";
|
|
|
|
+ $var(res) = http_connect("lisa", "", "$avp(gurka)");
|
|
|
|
+ xlog("L_ERR", "-- Lisa http_client connection: $avp(gurka) Result $var(res)\n");
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|
|
|
|
+
|