Mercurial > prosody-hg
comparison 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 |
| parents | 7006ccbf22a9 |
| children | 18ebc3874364 |
comparison
equal
deleted
inserted
replaced
| 5351:901ed253bbf7 | 5353:8c3f28f5c1c1 |
|---|---|
| 186 if not ok and err ~= "timeout" then | 186 if not ok and err ~= "timeout" then |
| 187 callback(nil, 0, req); | 187 callback(nil, 0, req); |
| 188 return nil, err; | 188 return nil, err; |
| 189 end | 189 end |
| 190 | 190 |
| 191 req.handler, req.conn = server.wrapclient(conn, req.host, port, listener, "*a", using_https and { mode = "client", protocol = "sslv23" }); | 191 local sslctx = false; |
| 192 if using_https then | |
| 193 sslctx = ex and ex.sslctx or { mode = "client", protocol = "sslv23" }; | |
| 194 end | |
| 195 | |
| 196 req.handler, req.conn = server.wrapclient(conn, req.host, port, listener, "*a", sslctx); | |
| 192 req.write = function (...) return req.handler:write(...); end | 197 req.write = function (...) return req.handler:write(...); end |
| 193 | 198 |
| 194 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 | 199 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 |
| 195 req.reader = request_reader; | 200 req.reader = request_reader; |
| 196 req.state = "status"; | 201 req.state = "status"; |
