changeset 2811:39156d6f7268

mod_auth_http_async: Allow LuaSocket to pollute the global scope (fixes #1033)
author Kim Alvefur <zash@zash.se>
date Tue, 31 Oct 2017 19:31:54 +0100
parents 9a3e51f348fe
children fd4a5ba12fa2
files mod_auth_http_async/mod_auth_http_async.lua
diffstat 1 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mod_auth_http_async/mod_auth_http_async.lua	Sat Oct 28 17:17:59 2017 +0200
+++ b/mod_auth_http_async/mod_auth_http_async.lua	Tue Oct 31 19:31:54 2017 +0100
@@ -26,9 +26,17 @@
 if rawget(_G, "base_parsed") == nil then
 	rawset(_G, "base_parsed", false)
 end
+if not have_async then -- FINE! Set your globals then
+	prosody.unlock_globals()
+	require "ltn12"
+	require "socket"
+	require "socket.http"
+	require "ssl.https"
+	prosody.lock_globals()
+end
 
 local function async_http_auth(url, username, password)
-module:log("debug", "async_http_auth()");
+	module:log("debug", "async_http_auth()");
 	local http = require "net.http";
 	local wait, done = async.waiter();
 	local content, code, request, response;
@@ -51,7 +59,8 @@
 end
 
 local function sync_http_auth(url,username, password)
-module:log("debug", "sync_http_auth()");
+	module:log("debug", "sync_http_auth()");
+	require "ltn12";
 	local http = require "socket.http";
 	local https = require "ssl.https";
 	local request;
@@ -113,4 +122,4 @@
 	});
 end
 
-module:provides("auth", provider);
\ No newline at end of file
+module:provides("auth", provider);