main.lua

changeset 3
8d3d5d8afbad
parent 2
13a1d5e43a2b
child 4
ae185012e7ba
equal deleted inserted replaced
2:13a1d5e43a2b 3:8d3d5d8afbad
35 if end_idx + 2 > #data then return; end 35 if end_idx + 2 > #data then return; end
36 local img = data:sub(start_idx, end_idx); 36 local img = data:sub(start_idx, end_idx);
37 assert(#img == img_size, "incorrect image size: actual:"..#img.." vs expected: "..img_size.." data: "..#data) 37 assert(#img == img_size, "incorrect image size: actual:"..#img.." vs expected: "..img_size.." data: "..#data)
38 response.body = data:sub(end_idx+3); 38 response.body = data:sub(end_idx+3);
39 events.fire_event("image-changed", { image = img }); 39 events.fire_event("image-changed", { image = img });
40 if not response.partial then
41 log("warn", "connection to upstream lost");
42 events.fire_event("connection-lost");
43 end
40 end); 44 end);
41 end); 45 end);
42 46
43 events.add_handler("no-clients", function () 47 events.add_handler("no-clients", function ()
44 request.conn:close(); 48 request.conn:close();

mercurial