# HG changeset patch
# User Matthew Wild <mwild1@gmail.com>
# Date 1365435627 -3600
# Node ID cbe9fa2d3787d0da409019970ac81db01a56cb7e
# Parent  92b88476873a36377349874a51ff02270b71a29d
net.http: Throw error when connecting to a http:// URL without LuaSec available

diff -r 92b88476873a -r cbe9fa2d3787 net/http.lua
--- a/net/http.lua	Mon Apr 08 15:53:18 2013 +0100
+++ b/net/http.lua	Mon Apr 08 16:40:27 2013 +0100
@@ -11,6 +11,8 @@
 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 @@
 	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