# HG changeset patch # User Matthew Wild # Date 1237679289 0 # Node ID 6737d005a84ac7969634f57c10cf9d45952a4f59 # Parent 00daf63c129e199cb9b80ae48aa94dfb895f65b8 net.http: Don't throw error on invalid URLs. Fixes #56. diff -r 00daf63c129e -r 6737d005a84a net/http.lua --- a/net/http.lua Sat Mar 21 21:47:09 2009 +0000 +++ b/net/http.lua Sat Mar 21 23:48:09 2009 +0000 @@ -114,6 +114,14 @@ 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 @@ 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