Skip to content

Commit

Permalink
Use better size for lengths of image
Browse files Browse the repository at this point in the history
  • Loading branch information
qpfiffer committed Oct 3, 2023
1 parent 0131a7d commit 46d8ca7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/views/Static.lua
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,10 @@ function Static:_attempt_read_static_file(filename)
end

local bytes = f:read("*all")
local siz = f:seek("end")
f:close()

return Response:init(bytes, 200, self:_get_ctype_from_filename(filename), string.len(bytes) + 1)
return Response:init(bytes, 200, self:_get_ctype_from_filename(filename), siz)
end

return nil
Expand Down Expand Up @@ -111,8 +112,9 @@ function Static:get(request, file)
local path = Utils.build_bump_path(subdomain_arg)
local f = assert(io.open(path .. "/" .. filename))
local bytes = f:read("*all")
local siz = f:seek("end")
f:close()
return Response:init(bytes, 200, "application/octet-stream", string.len(bytes) + 1)
return Response:init(bytes, 200, self:_get_ctype_from_filename(filename), siz)
end
return Utils.error404()
end
Expand Down

0 comments on commit 46d8ca7

Please sign in to comment.