From 4cc896c1e1577841bb748acd62865909293290cc Mon Sep 17 00:00:00 2001 From: lxsang Date: Wed, 4 Dec 2019 19:51:26 +0100 Subject: [PATCH] fix --- os/controllers/VFSController.lua | 30 +----------------------------- os/libs/shared.lua | 7 +------ silk/BaseController.lua | 7 +------ 3 files changed, 3 insertions(+), 41 deletions(-) diff --git a/os/controllers/VFSController.lua b/os/controllers/VFSController.lua index 749d85d..01872c2 100644 --- a/os/controllers/VFSController.lua +++ b/os/controllers/VFSController.lua @@ -82,35 +82,7 @@ function VFSController:get(...) local vfsfile = utils.decodeURI(uri) local r, m = require("vfs").checkperm(vfsfile, "read") if r then - local mime = std.mimeOf(m) - local finfo = ulib.file_stat(m) - local len = tostring(math.floor(finfo.size)) - local len1 = tostring(math.floor(finfo.size - 1)) - if mime == "audio/mpeg" then - std.status(200, "OK") - std.custom_header("Pragma", "public") - std.custom_header("Expires", "0") - std.custom_header("Content-Type", mime) - std.custom_header("Content-Length", len) - std.custom_header("Content-Disposition", "inline; filename=" .. std.basename(m)) - std.custom_header("Content-Range:", "bytes 0-" .. len1 .. "/" .. len) - std.custom_header("Accept-Ranges", "bytes") - std.custom_header("X-Pad", "avoid browser bug") - std.custom_header("Content-Transfer-Encoding", "binary") - std.custom_header("Cache-Control", "no-cache, no-store") - std.custom_header("Connection", "Keep-Alive") - std.custom_header("Etag", "a404b-c3f-47c3a14937c80") - else - std.status(200, "OK") - std.custom_header("Content-Type", mime) - std.custom_header("Content-Length", len) - end - std.header_flush() - if std.is_bin(m) then - std.fb(m) - else - std.f(m) - end + std.sendFile(m) else fail(m) end diff --git a/os/libs/shared.lua b/os/libs/shared.lua index aab05cc..6a576ec 100644 --- a/os/libs/shared.lua +++ b/os/libs/shared.lua @@ -31,12 +31,7 @@ shared.get = function(sharedid) else local p = shared.ospath(sharedid) - std.header(std.mimeOf(p)) - if std.is_bin(p) then - std.fb(p) - else - std.f(p) - end + std.sendFile(p) end end diff --git a/silk/BaseController.lua b/silk/BaseController.lua index 359fd81..29644ad 100644 --- a/silk/BaseController.lua +++ b/silk/BaseController.lua @@ -97,12 +97,7 @@ function AssetController:get(...) if self.registry.fileaccess and ulib.exists(path) then local mime = std.mimeOf(path) if POLICY.mimes[mime] then - std.header(mime) - if std.isBinary(path) then - std.fb(path) - else - std.f(path) - end + std.sendFile(path) else self:error("Access forbidden: "..path) end