Mercurial > prosody-hg
comparison net/http.lua @ 5948:1341384628ec
net.http: assert() for socket creation success so it doesn't silently fail (thanks daurnimator)
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Mon, 16 Dec 2013 23:24:16 +0000 |
| parents | 520671c3159c |
| children | bd1d1c29a7e7 4220ffb87b22 |
comparison
equal
deleted
inserted
replaced
| 5944:f3817912e8b2 | 5948:1341384628ec |
|---|---|
| 18 | 18 |
| 19 local t_insert, t_concat = table.insert, table.concat; | 19 local t_insert, t_concat = table.insert, table.concat; |
| 20 local pairs = pairs; | 20 local pairs = pairs; |
| 21 local tonumber, tostring, xpcall, select, traceback = | 21 local tonumber, tostring, xpcall, select, traceback = |
| 22 tonumber, tostring, xpcall, select, debug.traceback; | 22 tonumber, tostring, xpcall, select, debug.traceback; |
| 23 local assert, error = assert, error | |
| 23 | 24 |
| 24 local log = require "util.logger".init("http"); | 25 local log = require "util.logger".init("http"); |
| 25 | 26 |
| 26 module "http" | 27 module "http" |
| 27 | 28 |
| 171 local sslctx = false; | 172 local sslctx = false; |
| 172 if using_https then | 173 if using_https then |
| 173 sslctx = ex and ex.sslctx or { mode = "client", protocol = "sslv23", options = { "no_sslv2" } }; | 174 sslctx = ex and ex.sslctx or { mode = "client", protocol = "sslv23", options = { "no_sslv2" } }; |
| 174 end | 175 end |
| 175 | 176 |
| 176 req.handler, req.conn = server.wrapclient(conn, host, port_number, listener, "*a", sslctx); | 177 req.handler, req.conn = assert(server.wrapclient(conn, host, port_number, listener, "*a", sslctx)); |
| 177 req.write = function (...) return req.handler:write(...); end | 178 req.write = function (...) return req.handler:write(...); end |
| 178 | 179 |
| 179 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 | 180 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 |
| 180 req.reader = request_reader; | 181 req.reader = request_reader; |
| 181 req.state = "status"; | 182 req.state = "status"; |
