# HG changeset patch # User Matthew Wild # Date 1451905411 0 # Node ID 13a1d5e43a2b93319c35e694ceaa4ad7fd55b10f # Parent 7eff79ea9a01c42b4cc9119df9f4abb64bb98b20 main.lua: Log upstream HTTP errors diff -r 7eff79ea9a01 -r 13a1d5e43a2b main.lua --- a/main.lua Sun Jan 03 17:30:35 2016 +0000 +++ b/main.lua Mon Jan 04 11:03:31 2016 +0000 @@ -5,6 +5,7 @@ local server = require "net.server_select"; local http = require "net.http"; local logger = require "util.logger"; +local log = logger.init("main"); events = require "util.events".new(); require "clients"; @@ -18,6 +19,10 @@ events.add_handler("have-clients", function () request = http.request(arg[1], {success_on_chunk=true}, function (data, code, response) + if code ~= 200 then + log("error", "Error from upstream: %s", tostring(code)); + return; + end local boundary = response.headers["content-type"]:match("; boundary=(.+)$").."\r\n"; if #data > #boundary and data:sub(1, #boundary) ~= boundary then print(string.format(("%02X "):rep(6), data:byte(1,6)));