修复 AEROWEB Cookie 提取:httpx session.cookies 替代 resp.cookies.jar
httpx 的 cookies API 与 requests 库不同,resp.cookies.jar 在 httpx 中不存在, 导致 PHPSESSID 提取失败、登录报错。改用 self.session.cookies.get() 直接读取。
This commit is contained in:
@@ -60,15 +60,14 @@ class AerowebSourceMixin:
|
||||
|
||||
try:
|
||||
# Step 1: get a fresh PHPSESSID
|
||||
resp = self._http_get(f"{self.AEROWEB_BASE}/login.php", timeout=self.timeout)
|
||||
# httpx follows redirects; grab PHPSESSID from the cookie jar
|
||||
sid = None
|
||||
for cookie in resp.cookies.jar:
|
||||
if cookie.name == "PHPSESSID":
|
||||
sid = cookie.value
|
||||
break
|
||||
# Use the shared httpx session so cookies persist across requests.
|
||||
resp = self.session.get(
|
||||
f"{self.AEROWEB_BASE}/login.php", timeout=self.timeout
|
||||
)
|
||||
# httpx stores cookies on the session; grab PHPSESSID from there.
|
||||
sid = self.session.cookies.get("PHPSESSID")
|
||||
if not sid:
|
||||
# Try extracting from Set-Cookie header
|
||||
# Fallback: parse Set-Cookie header directly
|
||||
set_cookie = resp.headers.get("set-cookie", "")
|
||||
for part in set_cookie.replace(",", ";").split(";"):
|
||||
part = part.strip()
|
||||
|
||||
Reference in New Issue
Block a user