net.http.server: Close file handle earlier
authorKim Alvefur <zash@zash.se>
Sun, 08 Jan 2023 13:51:30 +0100
changeset 12837 8cbb109ff7ec
parent 12836 19365e0c0ddd
child 12839 6a97d448cb1e
net.http.server: Close file handle earlier Frees unneeded resources earlier, so they're not held on to while potentially sending the chunk trailer.
net/http/server.lua
--- a/net/http/server.lua	Sun Jan 08 13:39:24 2023 +0100
+++ b/net/http/server.lua	Sun Jan 08 13:51:30 2023 +0100
@@ -378,11 +378,11 @@
 			response.conn:write(chunk);
 		else
 			incomplete[response.conn] = nil;
+			if f.close then f:close(); end
 			if chunked then
 				response.conn:write("0\r\n\r\n");
 			end
 			-- io.write("\n");
-			if f.close then f:close(); end
 			return response:done();
 		end
 	end