🐛 (shelf): 详情页被拦不再误判登录失效,404 的书 7 天内不再重试
This commit is contained in:
1 parent
d736b69cdd
commit
b6b137a4b4
3 files changed
+56
-6
No files matched your search
@@ -103,9 +103,13 @@ end
|
||||
---@param path string
|
||||
---@param cookie string|nil
|
||||
---@param cb fun(html: string|nil, err: string|nil)
|
||||
---@param soft boolean|nil 公开页面:带 Cookie 被 302/403 拦时不判登录失效,改用匿名再取一次
|
||||
---@return HttpJob
|
||||
local function webGet(path, cookie, cb, cache_ttl)
|
||||
return Request.get(WEB .. path, {
|
||||
local webGet
|
||||
function webGet(path, cookie, cb, cache_ttl, soft)
|
||||
local job
|
||||
local handle = { cancel = function() if job then job.cancel() end end }
|
||||
job = Request.get(WEB .. path, {
|
||||
headers = headers(cookie),
|
||||
timeout = require("http.timeout").net(1),
|
||||
cache_ttl = cache_ttl,
|
||||
@@ -113,7 +117,11 @@ local function webGet(path, cookie, cb, cache_ttl)
|
||||
if not raw then
|
||||
local code = res and tonumber(res.code)
|
||||
if cookie and cookie ~= "" and (code == 302 or code == 403) then
|
||||
cb(nil, loginGone(cookie or ""))
|
||||
if soft then
|
||||
job = webGet(path, nil, cb, cache_ttl, true)
|
||||
else
|
||||
cb(nil, loginGone(cookie or ""))
|
||||
end
|
||||
else
|
||||
cb(nil, err and tostring(err) or _("请求失败"))
|
||||
end
|
||||
@@ -121,6 +129,7 @@ local function webGet(path, cookie, cb, cache_ttl)
|
||||
end
|
||||
cb(raw)
|
||||
end)
|
||||
return handle
|
||||
end
|
||||
|
||||
---@param wire table|nil
|
||||
@@ -429,7 +438,7 @@ function Client.detailAsync(book_id, cb)
|
||||
end
|
||||
|
||||
cb(info)
|
||||
end)
|
||||
end, nil, true)
|
||||
end
|
||||
|
||||
---@param book_id string
|
||||
|
||||
Reference in new issue
Block a user