From fe97c773a6b8e61c6aee0511e30164e2fbdd6091 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sun, 8 Jan 2023 13:35:04 +0100 Subject: net.http.server: Fix #1789 Unregistering the response before sending the trailer of the chunked transfer encoding prevents opportunistic writes from being invoked and running this code again when, which may cause an error when closing the file handle a second time. Normally the file size is known, so no chuck headers are sent. --- net/http/server.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/http/server.lua b/net/http/server.lua index 97e15e42..4ebf96a1 100644 --- a/net/http/server.lua +++ b/net/http/server.lua @@ -377,12 +377,12 @@ function _M.send_file(response, f) -- io.write("."); io.flush(); response.conn:write(chunk); else + incomplete[response.conn] = nil; if chunked then response.conn:write("0\r\n\r\n"); end -- io.write("\n"); if f.close then f:close(); end - incomplete[response.conn] = nil; return response:done(); end end -- cgit v1.2.3