Diff

mod_pubsub_hub/mod_pubsub_hub.lua @ 1325:b21236b6b8d8

Backed out changeset 853a382c9bd6
author Kim Alvefur <zash@zash.se>
date Fri, 28 Feb 2014 15:37:55 +0100
parent 1324:853a382c9bd6
child 1458:e9d164e694e7
line wrap: on
line diff
--- a/mod_pubsub_hub/mod_pubsub_hub.lua	Fri Feb 28 15:36:06 2014 +0100
+++ b/mod_pubsub_hub/mod_pubsub_hub.lua	Fri Feb 28 15:37:55 2014 +0100
@@ -2,14 +2,15 @@
 --
 -- This file is MIT/X11 licensed.
 
-local http_request, formdecode, formencode = import("net.http", "request", "formdecode", "formencode");
+local http = require "net.http";
+local formdecode = http.formdecode;
+local formencode = http.formencode;
 local uuid = require "util.uuid".generate;
 local hmac_sha1 = require "util.hmac".sha1;
 local json_encode = require "util.json".encode;
 local time = os.time;
 local m_min, m_max = math.min, math.max;
 local tostring = tostring;
-
 local xmlns_pubsub = "http://jabber.org/protocol/pubsub";
 local xmlns_pubsub_event = xmlns_pubsub .. "#event";
 local subs_by_topic = module:shared"subscriptions";
@@ -90,7 +91,7 @@
 			module:log("debug", require"util.serialization".serialize(verify_modes));
 			if verify_modes["async"] then
 				module:log("debug", "Sending async verification request to %s for %s", tostring(callback_url), tostring(subscription));
-				http_request(callback_url, nil, function(body, code)
+				http.request(callback_url, nil, function(body, code)
 					if body == challenge and code > 199 and code < 300 then
 						if not subscription.want_state then
 							module:log("warn", "Verification of already verified request, probably");
@@ -108,7 +109,7 @@
 				end)
 				return 202;
 			elseif verify_modes["sync"] then
-				http_request(callback_url, nil, function(body, code)
+				http.request(callback_url, nil, function(body, code)
 					if body == challenge and code > 199 and code < 300 then
 						if not subscription.want_state then
 							module:log("warn", "Verification of already verified request, probably");
@@ -160,7 +161,7 @@
 						["hub.lease_seconds"] = subscription.lease_seconds,
 						["hub.verify_token"] = subscription.verify_token,
 					}
-					http_request(callback_url, nil, function(body, code)
+					http.request(callback_url, nil, function(body, code)
 						if body == challenge and code > 199 and code < 300 then
 							subscription.expires = now + subscription.lease_seconds;
 						end
@@ -200,7 +201,7 @@
 	if subscription.secret then
 		headers["X-Hub-Signature"] = "sha1="..hmac_sha1(subscription.secret, body, true);
 	end
-	http_request(subscription.callback, { method = "POST", body = body, headers = headers }, function(body, code)
+	http.request(subscription.callback, { method = "POST", body = body, headers = headers }, function(body, code)
 		if code >= 200 and code <= 299 then
 			module:log("debug", "Delivered");
 		else