From: Marek VavruĊĦa Date: Mon, 2 Apr 2018 23:42:42 +0000 (-0700) Subject: modules/http: added an error handler to HTTP streams X-Git-Tag: v3.2.0~35^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fb5991a86d3f8432692b3e0da060d14758dfdb43;p=thirdparty%2Fknot-resolver.git modules/http: added an error handler to HTTP streams Instead of throwing an error in the HTTP handler, server should log it. This covers errors like client disconnecting before reading the response body etc. --- diff --git a/modules/http/http.lua b/modules/http/http.lua index f3c4e4936..dabdeba1c 100644 --- a/modules/http/http.lua +++ b/modules/http/http.lua @@ -322,6 +322,16 @@ function M.add_interface(conf) ctx = crt and tlscontext(crt, key), tls = conf.tls, onstream = routes, + -- Log errors, but do not throw + onerror = function(myserver, context, op, err, errno) -- luacheck: ignore 212 + local msg = '[http] ' .. op .. ' on ' .. tostring(context) .. ' failed' + if err then + msg = msg .. ': ' .. tostring(err) + end + if verbose() then + log(msg) + end + end, } -- Manually call :listen() so that we are bound before calling :localname() if s then