aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/http.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/net/http.lua b/net/http.lua
index 1ecbf410..1d22d3e5 100644
--- a/net/http.lua
+++ b/net/http.lua
@@ -114,6 +114,14 @@ local function handleerr(err) log("error", "Traceback[http]: %s: %s", tostring(e
function request(u, ex, callback)
local req = url.parse(u);
+ if not (req and req.host) then
+ return nil, "invalid-url";
+ end
+
+ if not req.path then
+ req.path = "/";
+ end
+
local custom_headers, body;
local default_headers = { ["Host"] = req.host, ["User-Agent"] = "Prosody XMPP Server" }
@@ -139,6 +147,7 @@ function request(u, ex, callback)
req.conn:settimeout(0);
local ok, err = req.conn:connect(req.host, req.port or 80);
if not ok and err ~= "timeout" then
+ callback(nil, 0, req);
return nil, err;
end