Comparison

net/http.lua @ 5950:bd1d1c29a7e7

Merge 0.9->0.10
author Matthew Wild <mwild1@gmail.com>
date Mon, 16 Dec 2013 23:32:11 +0000
parent 5776:bd0ff8ae98a8
parent 5948:1341384628ec
child 5964:ad04170d6533
child 6382:57d23c26039b
comparison
equal deleted inserted replaced
5945:51ead0aa3a02 5950:bd1d1c29a7e7
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";