Software /
code /
prosody
Diff
net/http.lua @ 5353:8c3f28f5c1c1
net.http: Allow passing an SSL context or options table to be used for HTTPS requests (thanks daurnimator)
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Wed, 20 Mar 2013 20:31:02 +0000 |
parent | 4977:7006ccbf22a9 |
child | 5354:18ebc3874364 |
line wrap: on
line diff
--- a/net/http.lua Sat Mar 16 17:46:43 2013 +0100 +++ b/net/http.lua Wed Mar 20 20:31:02 2013 +0000 @@ -188,7 +188,12 @@ 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