访问远程数据相关函数 ctyun.querygetcache 函数信息详见下表: 项目 描述 语法 res, err ctyun.querygetcache(cachehost, cacheurl, cachemode, ttl, uri?, args?, timeouts?) 作用 回源拉取文件并缓存,得到响应内容可编辑。如m3u8改写,请求得到响应体,使用Lua脚本对响应体进行编辑后,重新计算ContentLength头部,调用ngx.print() 响应客户端经过处理后的响应。 入参 cachehost: 缓存host。示例:ctyun.cn。 cacheurl: 缓存url。示例:/static/origin.m3u8。 cachemode: 固定缓存时间/跟随源站缓存(定值 "fixed" / “follow”)。默认为fixed, 非合法输入初始化为默认值。 ttl: 缓存时间,单位秒。如果是固定缓存,设置缓存多久; 如果跟随源站也可以设置默认值(秒)。 uri:请求uri,缺省为当前的请求uri。示例:/static/origin.m3u8。 args:请求参数,缺省为当前的请求参数,支持luastring和luatable两种格式。示例:a1&b2或者{a1,b2}。 timeouts:超时时间,array table格式。分别为connecttimeout、sendtimeout、readtimout,单位ms。缺省为15000 60000 60000。示例:{15000, 15000, 15000}。 返回值 res:响应结果,luatable类型,{ status, headers, body }。 err:错误信息。 示例: reasonml local res, err ctyun.querygetcache("ctyun.cn", "/static/origin.m3u8", "fixed", 86400, "/static/origin.m3u8", "a1&b2", {15000, 15000, 15000}) if err then return end headers for k, v in pairs(res.headers) do ctyun.resp.setheader(k, v) end status ctyun.resp.setcode(res.status) local status res.status if status > 299 or status < 200 then ctyun.resp.setoutput(res.body) end process body local body res.body if body then 对响应的处理, processbody仅用于说明 body processbody(body) 重写ContentLength响应头,输出响应 ctyun.resp.setheader("ContentLength",