summaryrefslogtreecommitdiff
path: root/misc/freeswitch/scripts/http_request.lua
diff options
context:
space:
mode:
authorJulian Pawlowski <julian.pawlowski@gmail.com>2013-01-28 14:17:52 +0100
committerJulian Pawlowski <julian.pawlowski@gmail.com>2013-01-28 14:17:52 +0100
commit8aa7de2636dcd22781b623d5c9270f5ecf8b85c2 (patch)
tree1bb5dc36fb28c96ad9be9a2357d380c2c24ee31e /misc/freeswitch/scripts/http_request.lua
parent39aa7132ceed3d4beab3a9b828e571bbfc67c07e (diff)
parent600574759573e48da9f5f82d4ff8a863b6830c95 (diff)
Merge branch 'develop'5.1-beta2
Diffstat (limited to 'misc/freeswitch/scripts/http_request.lua')
-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);