From 67a7545756b8a00aebbcf5810b8e9314c0f8ddd8 Mon Sep 17 00:00:00 2001 From: basheer-cloud Date: Wed, 8 Apr 2026 23:32:52 -0400 Subject: [PATCH] Set a timeout on auth retry HTTP calls --- scripts/hap/auth_retry.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/hap/auth_retry.py b/scripts/hap/auth_retry.py index c3b7b3b..17afbe4 100644 --- a/scripts/hap/auth_retry.py +++ b/scripts/hap/auth_retry.py @@ -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 响应") @@ -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 响应")