aboutsummaryrefslogtreecommitdiffstats
path: root/net/http.lua
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2013-04-08 16:40:27 +0100
committerMatthew Wild <mwild1@gmail.com>2013-04-08 16:40:27 +0100
commit131f865ac287fd7a5e07c993672f1337d0c85efc (patch)
tree973f86a163649231944da721d0dbb8d605ea3933 /net/http.lua
parenta5e2b65c010611d2d3563d82f025d6f6c1472183 (diff)
downloadprosody-131f865ac287fd7a5e07c993672f1337d0c85efc.tar.gz
prosody-131f865ac287fd7a5e07c993672f1337d0c85efc.zip
net.http: Throw error when connecting to a http:// URL without LuaSec available
Diffstat (limited to 'net/http.lua')
-rw-r--r--net/http.lua5
1 files changed, 5 insertions, 0 deletions
diff --git a/net/http.lua b/net/http.lua
index a1e4e523..ec55af92 100644
--- a/net/http.lua
+++ b/net/http.lua
@@ -11,6 +11,8 @@ local b64 = require "util.encodings".base64.encode;
local url = require "socket.url"
local httpstream_new = require "util.httpstream".new;
+local ssl_available = pcall(require, "ssl");
+
local server = require "net.server"
local t_insert, t_concat = table.insert, table.concat;
@@ -177,6 +179,9 @@ function request(u, ex, callback)
req.method, req.headers, req.body = method, headers, body;
local using_https = req.scheme == "https";
+ if using_https and not ssl_available then
+ error("SSL not available, unable to contact https URL");
+ end
local port = tonumber(req.port) or (using_https and 443 or 80);
-- Connect the socket, and wrap it with net.server