miduo_client/Assets/ManagedResources/~Lua/Modules/Net/HttpManager.lua

33 lines
1.0 KiB
Lua
Raw Normal View History

2021-11-09 10:49:37 +08:00
require("Base.HttpCrypt")
HttpManager = {}
-- 加密密钥
local CRYPT_KEY = "d53b3e8ef74bf72d8aafce3a1c8671a0"
-- 是否要加密
local isCrypt = AppConst.Platform == "IOS" --or AppConst.Platform == "EDITOR"
-- 计数器
local _Counter = 0
-- GET 请求
function HttpManager:SendGetHttp(url, callback, _, _, failCB)
local request = url
_Counter = _Counter + 1
local count = _Counter
LogWarn("Http请求" .. count.. ""..request)
if isCrypt then
local urlList = string.split(url, "?")
urlList[2] = HTTP_ENCRYPT(urlList[2], CRYPT_KEY)
request = urlList[1] .. "?crypt=" .. urlList[2]
LogWarn("Http加密请求" .. count.. ""..request)
end
networkMgr:SendGetHttp(request, function(msg)
LogWarn("Http请求" .. count.. "结果:"..msg)
if isCrypt then
msg = HTTP_DECRYPT(msg, CRYPT_KEY)
LogWarn("Http请求" .. count.. "结果解密:"..msg)
end
if callback then
callback(msg)
end
end, nil, nil, failCB)
end
return HttpManager