summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorspag <spag@golwen.net>2013-01-24 15:37:11 +0100
committerspag <spag@golwen.net>2013-01-24 15:37:11 +0100
commit5f5ea1d06686ec5cd31cf8b9db177191fa7e66fd (patch)
tree8c772b3353be7bf88ae4b6178cf65fb98861573b
parentf4d1151238fbf01b436884ae89367a53b4360014 (diff)
http_request added
-rw-r--r--misc/freeswitch/scripts/http_request.lua31
1 files changed, 31 insertions, 0 deletions
diff --git a/misc/freeswitch/scripts/http_request.lua b/misc/freeswitch/scripts/http_request.lua
new file mode 100644
index 0000000..8acdcb6
--- /dev/null
+++ b/misc/freeswitch/scripts/http_request.lua
@@ -0,0 +1,31 @@
+-- Gemeinschaft 5 fire and forget http request script
+-- (c) AMOOMA GmbH 2013
+--
+
+http = require('socket.http');
+http.TIMEOUT = 10;
+http.USERAGENT = 'Gemeinschaft 5';
+
+local log_identifier = argv[1];
+local url = argv[2];
+local user = argv[3];
+local password = argv[4];
+
+if not log_identifier or not url then
+ return;
+end
+
+-- Set logger
+require 'common.log';
+local log = common.log.Log:new();
+log.prefix = '#R# [' .. log_identifier .. '] ';
+
+local headers = {};
+
+if user and password then
+ mime = require('mime');
+ headers.Authorization = 'Basic ' .. (mime.b64(user .. ':' .. password));
+end
+
+local success, result, response_headers = http.request{url = url, headers = headers };
+log:debug('HTTP_REQUEST - url: ', url, ', auth: ', tostring(headers.Authorization ~= nil), ', result: ', result);