修复ws连接后被服务器断开时信息解析错误

This commit is contained in:
MrZ626
2021-03-28 03:38:48 +08:00
parent 467eee308f
commit 411d4dc1b3

View File

@@ -131,14 +131,11 @@ while true do--Running
readCHN:push(op)
if op==8 then--close
SOCK:close()
if res:sub(1,4)=="HTTP"then
local code=res:find(" ")
code=res:sub(code+1,code+3)
local res=res:sub(res:find("\n\n")+1)
reason=JSON.decode(res)if reason then reason=reason.message end
readCHN:push(code.."-"..(reason or res))
if type(res)=="string"then
local reason=JSON.decode(res)
readCHN:push(reason and reason.message or"Server Error")
else
readCHN:push(string.format("%d-%s",shl(byte(res,1),8)+byte(res,2),res:sub(3,-3)))
readCHN:push("Server Error")
end
else
readCHN:push(res)