net.http: Allow passing an SSL context or options table to be used for HTTPS requests...
authorMatthew Wild <mwild1@gmail.com>
Wed, 20 Mar 2013 20:31:02 +0000 (20:31 +0000)
committerMatthew Wild <mwild1@gmail.com>
Wed, 20 Mar 2013 20:31:02 +0000 (20:31 +0000)
net/http.lua

index 273eee090535196ebbf06309dbf832da6507b10b..9ed837e20a625c84674f2f1bc75bbf56a5a4d157 100644 (file)
@@ -188,7 +188,12 @@ function request(u, ex, callback)
                return nil, err;
        end
        
-       req.handler, req.conn = server.wrapclient(conn, req.host, port, listener, "*a", using_https and { mode = "client", protocol = "sslv23" });
+       local sslctx = false;
+       if using_https then
+               sslctx = ex and ex.sslctx or { mode = "client", protocol = "sslv23" };
+       end
+
+       req.handler, req.conn = server.wrapclient(conn, req.host, port, listener, "*a", sslctx);
        req.write = function (...) return req.handler:write(...); end
        
        req.callback = function (content, code, request, response) log("debug", "Calling callback, status %s", code or "---"); return select(2, xpcall(function () return callback(content, code, request, response) end, handleerr)); end