fix(cmcc): parse_curl 头键大小写不敏感(Reqable 等导出 Cookie 大写 C)

号2素材实测踩到:mitm/Reqable 导出的请求头是 'Cookie'(大写),
parse_curl 的 headers.get('cookie') 大小写敏感 → 自检误报缺 cookie 头。
改用小写化视图做自检判定,原始头键仍原样保留(服务端/request 都大小写不敏感)。
This commit is contained in:
2026-11-07 18:50:04 +08:00
parent a9bdd048f5
commit 57a49ab7f5
4 changed files with 501 additions and 2 deletions

View File

@@ -233,12 +233,14 @@ def parse_curl(raw):
if not url or not body:
raise ValueError("cURL 里没解析到 URL 或 body")
headers = {k: v for k, v in headers.items() if k.lower() not in STRIP_HEADERS}
# 大小写不敏感视图(Reqable 等导出的头键大小写不定:Cookie/COOKIE)
lower = {k.lower(): v for k, v in headers.items()}
problems = [] # 解析后自检:坏 cURL 在这里就报,别到线上当素材失效
if "autoLogin" not in url:
problems.append("URL 不含 autoLogin")
if not headers.get("xs"):
if not lower.get("xs"):
problems.append("缺 xs 头")
if not headers.get("cookie"):
if not lower.get("cookie"):
problems.append("缺 cookie 头")
if not (1300 <= len(body) <= 1700):
problems.append("body 长度 %d 不在 1472/1516±10%% 内" % len(body))