aboutsummaryrefslogtreecommitdiffstats
path: root/net/http.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2015-08-20 13:05:22 +0200
committerKim Alvefur <zash@zash.se>2015-08-20 13:05:22 +0200
commit6ef7c4d80892f486d71e660b054bdfdb993c8528 (patch)
tree103fd7d9396b60b9f76071a009c54d3ca9d35744 /net/http.lua
parenta9029bd099734436154fc4e794d3b958e54d1943 (diff)
parentd32f36b2817739d7f8d5f1208a3009b7be379562 (diff)
downloadprosody-6ef7c4d80892f486d71e660b054bdfdb993c8528.tar.gz
prosody-6ef7c4d80892f486d71e660b054bdfdb993c8528.zip
Merge 0.10->trunk
Diffstat (limited to 'net/http.lua')
-rw-r--r--net/http.lua34
1 files changed, 18 insertions, 16 deletions
diff --git a/net/http.lua b/net/http.lua
index 357b7452..b78f8438 100644
--- a/net/http.lua
+++ b/net/http.lua
@@ -23,7 +23,7 @@ local assert, error = assert, error
local log = require "util.logger".init("http");
-module "http"
+local _ENV = nil;
local requests = {}; -- Open requests
@@ -75,6 +75,13 @@ function listener.ondetach(conn)
requests[conn] = nil;
end
+local function destroy_request(request)
+ if request.conn then
+ request.conn = nil;
+ request.handler:close()
+ end
+end
+
local function request_reader(request, data, err)
if not request.parser then
local function error_cb(reason)
@@ -106,7 +113,7 @@ local function request_reader(request, data, err)
end
local function handleerr(err) log("error", "Traceback[http]: %s", traceback(tostring(err), 2)); end
-function request(u, ex, callback)
+local function request(u, ex, callback)
local req = url.parse(u);
if not (req and req.host) then
@@ -184,17 +191,12 @@ function request(u, ex, callback)
return req;
end
-function destroy_request(request)
- if request.conn then
- request.conn = nil;
- request.handler:close()
- end
-end
-
-local urlencode, urldecode = util_http.urlencode, util_http.urldecode;
-local formencode, formdecode = util_http.formencode, util_http.formdecode;
-
-_M.urlencode, _M.urldecode = urlencode, urldecode;
-_M.formencode, _M.formdecode = formencode, formdecode;
-
-return _M;
+return {
+ request = request;
+
+ -- COMPAT
+ urlencode = util_http.urlencode;
+ urldecode = util_http.urldecode;
+ formencode = util_http.formencode;
+ formdecode = util_http.formdecode;
+};