Comparison

net/http.lua @ 5505:0b6a99e6c1b1

mod_c2s, mod_s2s, net.http, net.http.server: Improve tracebacks (omit traceback function), to make it clearer where an error occured
author Matthew Wild <mwild1@gmail.com>
date Mon, 22 Apr 2013 12:35:52 +0100
parent 5488:0880a079d830
child 5714:520671c3159c
comparison
equal deleted inserted replaced
5504:b760b5f0c2b0 5505:0b6a99e6c1b1
15 local ssl_available = pcall(require, "ssl"); 15 local ssl_available = pcall(require, "ssl");
16 16
17 local server = require "net.server" 17 local server = require "net.server"
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, ipairs = pairs, ipairs; 20 local pairs = pairs;
21 local tonumber, tostring, xpcall, select, debug_traceback, char, format = 21 local tonumber, tostring, xpcall, select, traceback =
22 tonumber, tostring, xpcall, select, debug.traceback, string.char, string.format; 22 tonumber, tostring, xpcall, select, debug.traceback;
23 23
24 local log = require "util.logger".init("http"); 24 local log = require "util.logger".init("http");
25 25
26 module "http" 26 module "http"
27 27
99 request.parser = httpstream_new(success_cb, error_cb, "client", options_cb); 99 request.parser = httpstream_new(success_cb, error_cb, "client", options_cb);
100 end 100 end
101 request.parser:feed(data); 101 request.parser:feed(data);
102 end 102 end
103 103
104 local function handleerr(err) log("error", "Traceback[http]: %s: %s", tostring(err), debug_traceback()); end 104 local function handleerr(err) log("error", "Traceback[http]: %s", traceback(tostring(err), 2)); end
105 function request(u, ex, callback) 105 function request(u, ex, callback)
106 local req = url.parse(u); 106 local req = url.parse(u);
107 107
108 if not (req and req.host) then 108 if not (req and req.host) then
109 callback(nil, 0, req); 109 callback(nil, 0, req);