Software /
code /
prosody
Diff
net/http/server.lua @ 9562:acf74ad0b795
Many things: switch from hacky multi-arg xpcall implementations to a standard util.xpcall
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 26 Oct 2018 19:32:00 +0100 |
parent | 9379:866cba3689f4 |
child | 9624:cc9dff0212f4 |
line wrap: on
line diff
--- a/net/http/server.lua Fri Oct 26 19:29:08 2018 +0100 +++ b/net/http/server.lua Fri Oct 26 19:32:00 2018 +0100 @@ -8,7 +8,7 @@ local pairs = pairs; local s_upper = string.upper; local setmetatable = setmetatable; -local xpcall = xpcall; +local xpcall = require "util.xpcall".xpcall; local traceback = debug.traceback; local tostring = tostring; local cache = require "util.cache"; @@ -88,8 +88,6 @@ }); local handle_request; -local _1, _2, _3; -local function _handle_request() return handle_request(_1, _2, _3); end local last_err; local function _traceback_handler(err) last_err = err; log("error", "Traceback[httpserver]: %s", traceback(tostring(err), 2)); end @@ -107,9 +105,7 @@ while sessions[conn] and #pending > 0 do local request = t_remove(pending); --log("debug", "process_next: %s", request.path); - --handle_request(conn, request, process_next); - _1, _2, _3 = conn, request, process_next; - if not xpcall(_handle_request, _traceback_handler) then + if not xpcall(handle_request, _traceback_handler, conn, request, process_next) then conn:write("HTTP/1.0 500 Internal Server Error\r\n\r\n"..events.fire_event("http-error", { code = 500, private_message = last_err })); conn:close(); end