Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions scripts/hap/auth_retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ def hap_web_post(

# proxies={} 绕过系统代理,避免 www.mingdao.com 连接超时
kwargs.setdefault("proxies", {})
resp = requests.post(url, headers=headers, **kwargs)
resp = requests.post(url, headers=headers, **kwargs, timeout=10.0)
if resp.status_code == 401:
print(f"[auth_retry] 检测到 401(POST {url}),正在自动刷新认证后重试...")
if refresh_auth(auth_path):
account_id, authorization, cookie = load_web_auth(auth_path)
headers = _build_headers(account_id, authorization, cookie, referer, extra_headers)
resp = requests.post(url, headers=headers, **kwargs)
resp = requests.post(url, headers=headers, **kwargs, timeout=10.0)
else:
print("[auth_retry] 认证刷新失败,返回原始 401 响应")

Expand All @@ -149,13 +149,13 @@ def hap_web_get(

# proxies={} 绕过系统代理,避免 www.mingdao.com 连接超时
kwargs.setdefault("proxies", {})
resp = requests.get(url, headers=headers, **kwargs)
resp = requests.get(url, headers=headers, **kwargs, timeout=10.0)
if resp.status_code == 401:
print(f"[auth_retry] 检测到 401(GET {url}),正在自动刷新认证后重试...")
if refresh_auth(auth_path):
account_id, authorization, cookie = load_web_auth(auth_path)
headers = _build_headers(account_id, authorization, cookie, referer, extra_headers)
resp = requests.get(url, headers=headers, **kwargs)
resp = requests.get(url, headers=headers, **kwargs, timeout=10.0)
else:
print("[auth_retry] 认证刷新失败,返回原始 401 响应")

Expand Down