Software /
code /
prosody
Diff
net/http.lua @ 6791:e813e8cf6046
Merge 0.10->trunk
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 20 Aug 2015 13:05:22 +0200 |
parent | 6502:8fed6ea12098 |
parent | 6780:647adfd8f738 |
child | 6826:17a4e89a4780 |
line wrap: on
line diff
--- a/net/http.lua Mon Aug 17 01:58:53 2015 +0200 +++ b/net/http.lua Thu Aug 20 13:05:22 2015 +0200 @@ -23,7 +23,7 @@ local log = require "util.logger".init("http"); -module "http" +local _ENV = nil; local requests = {}; -- Open requests @@ -75,6 +75,13 @@ 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 @@ 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 @@ 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; +};