Lua http请求挂起

时间:2014-03-28 08:40:49

标签: http lua request

我用超时调用lua http.request。在我发出http请求之前,如果网络关闭,我将获得http状态为网络无法访问,但如果网络在Http请求后不可用,它就会挂起。有没有办法处理这个问题。

local isHttps = string.match(type(url) == "table" and url.url or url, "^https:") 
local http = isHttps and require("ssl.https") or require("socket.http")
local r,s,h 
if isHttps then 
    http.TIMEOUT = 300 
    r,s,h = http.request ({
        url = url,
        method = "GET",
        sink = ltn12.sink.table(results),
        headers= ["Cache-Control"] 
        = "no-cache"["X-Token"]=config.token
    }) 

0 个答案:

没有答案