1
0
mirror of https://github.com/lxsang/antd-lua-plugin synced 2025-02-13 23:12:47 +01:00
This commit is contained in:
lxsang 2019-12-04 19:52:26 +01:00
parent fe5fe09754
commit 9c233ce3f1
4 changed files with 34 additions and 0 deletions

View File

@ -6,6 +6,7 @@ package.cpath = __api__.apiroot..'/?.so'
require("std") require("std")
require("utils") require("utils")
require("extra_mime") require("extra_mime")
ulib = require("ulib")
-- set session -- set session
SESSION = {} SESSION = {}

View File

@ -41,3 +41,35 @@ function std.isBinary(name)
return bin return bin
end end
end end
function std.sendFile(m)
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
end

View File

@ -117,6 +117,7 @@ end
function std.is_file(f) function std.is_file(f)
return std.is_dir(f) == false return std.is_dir(f) == false
end end
std.ws.TEXT = 1 std.ws.TEXT = 1
std.ws.BIN = 2 std.ws.BIN = 2
std.ws.CLOSE = 8 std.ws.CLOSE = 8

BIN
dist/lua-0.5.2b.tar.gz vendored

Binary file not shown.