net.http.files: Fix #1927

Problem was type confusion where the `data` variable was expected to be
a string later but ended up being the table stored in the cache.

Here a different variable is used for the cache entry and the data.
13.0
Kim Alvefur 1 year ago
parent 052d497dee
commit d723c0a6dd
  1. 11
      net/http/files.lua

@ -90,11 +90,12 @@ local function serve(opts)
return 304;
end
local data = cache:get(orig_path);
if data and data.etag == etag then
response_headers.content_type = data.content_type;
data = data.data;
cache:set(orig_path, data);
local data;
local cached = cache:get(orig_path);
if cached and cached.etag == etag then
response_headers.content_type = cached.content_type;
data = cached.data;
cache:set(orig_path, cached);
elseif attr.mode == "directory" and path then
if full_path:sub(-1) ~= "/" then
local dir_path = { is_absolute = true, is_directory = true };

Loading…
Cancel
Save