aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2009-03-21 23:48:09 +0000
committerMatthew Wild <mwild1@gmail.com>2009-03-21 23:48:09 +0000
commit51fd2073f805a4ca9dfd7de68c0a722c33094780 (patch)
tree5906be53edfe45e1850008767d4dca40fd2fd427
parenta3b7fc26cbab3b3d71bc2cf0f974a6b0bf7be755 (diff)
downloadprosody-51fd2073f805a4ca9dfd7de68c0a722c33094780.tar.gz
prosody-51fd2073f805a4ca9dfd7de68c0a722c33094780.zip
net.http: Don't throw error on invalid URLs. Fixes #56.
-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