2 # Test of the new http_client API module
4 # (C) 2016 Edvina AB, Sollentuna, Sweden. All rights reserved.
12 # ------------------ module loading ----------------------------------
13 # Set a path to known locations for modules
15 mpath="/usr/local/lib64/kamailio/modules:/usr/local/lib/kamailio/modules:/usr/lib64/kamailio/modules:/usr/lib/kamailio/modules"
16 loadmodule "pv.so" # For pseudo-variable support in log messages etc
17 loadmodule "xlog.so" # For extended logging with pseudovariables
18 loadmodule "kex.so" # Kamailio extensions:
19 # Script flags and basic mi commands (version, pwd, get_statistics)
21 loadmodule "tm.so" # Transactions are needed in order to fork
22 loadmodule "tmx.so" # Kamailio extras to TM
24 loadmodule "sl.so" # Stateless replies - needed by registrar.so
25 loadmodule "rtimer.so" # For ticks
26 loadmodule "htable.so" # For init event route
27 loadmodule "http_client.so" # THe CURL module
28 loadmodule "httpapitest.so" # THe CURL module
29 loadmodule "cfgutils.so" # Memory debugging
33 modparam("http_client", "connection_timeout", 42);
34 modparam("http_client", "keep_connections", 1);
35 modparam("http_client", "maxdatasize", 1000);
36 modparam("http_client", "useragent", "Olle's Peace and Restful little HTTP grabber 42.3");
38 modparam("http_client", "httpcon", "lisa=>https://www.kamailio.org/w/");
41 # ------------------------- request routing logic -------------------
43 sl_send_reply(400, "Do not wake me up");
48 xlog("L_INFO", "<-- Incoming response: $rs $rr - from $si\n");
51 branch_route[BRANCH_ROUTE]
53 xlog("L_INFO", " --> Outgoing branch $T_branch_idx : $rm from $si to $ru \n");
58 xlog("ONSEND --> Sending from $sndfrom(proto):$sndfrom(ip):$sndfrom(port) to $sndto(proto):$sndto(ip):$sndto(port) \n");
61 # This route is executed at Kamailio start
62 event_route[htable:mod-init]
64 xlog("L_ERR", "### Kamailio starting $timef(HH:mm) \n");
66 $var(res) = http_connect("lisa", "", "$avp(gurka)");
67 xlog("L_ERR", "-- Lisa http_client connection: $avp(gurka) Result $var(res)\n");