From 5f5ea1d06686ec5cd31cf8b9db177191fa7e66fd Mon Sep 17 00:00:00 2001 From: spag Date: Thu, 24 Jan 2013 15:37:11 +0100 Subject: http_request added --- misc/freeswitch/scripts/http_request.lua | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 misc/freeswitch/scripts/http_request.lua (limited to 'misc/freeswitch/scripts/http_request.lua') 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); -- cgit v1.2.3