mod_auth_http_async: Use "net.http" for async case.
authorJC Brand <jc@opkode.com>
Tue, 21 Mar 2017 09:31:13 +0000
changeset 2634 96eb1c4f9ff7
parent 2633 a11568bfaf4c
child 2635 2bfa7d476092
mod_auth_http_async: Use "net.http" for async case.
mod_auth_http_async/mod_auth_http_async.lua
--- a/mod_auth_http_async/mod_auth_http_async.lua	Tue Mar 21 09:14:03 2017 +0000
+++ b/mod_auth_http_async/mod_auth_http_async.lua	Tue Mar 21 09:31:13 2017 +0000
@@ -8,8 +8,6 @@
 --
 
 local new_sasl = require "util.sasl".new;
-local http = require "socket.http";
-local https = require "ssl.https";
 local base64 = require "util.encodings".base64.encode;
 local have_async, async = pcall(require, "util.async");
 
@@ -30,6 +28,7 @@
 end
 
 local function async_http_auth(url, username, password)
+	local http = require "net.http";
 	local wait, done = async.waiter();
 	local content, code, request, response;
 	local ex = {
@@ -51,6 +50,8 @@
 end
 
 local function sync_http_auth(url)
+	local http = require "socket.http";
+	local https = require "ssl.https";
 	local request;
 	if string.sub(url, 1, string.len('https')) == 'https' then
 		request = https.request;