fix(UME): 改用HTTPTransport并增强token失败提示

UME 客户端改为显式 HTTPTransport 以匹配现网可用链路,前端在手动登录/续期或断开 token 失败时优先展示后端返回的错误信息,便于快速定位问题。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
oliver 2026-05-08 19:15:10 +08:00
parent 267eddb273
commit 2c0b52d972
2 changed files with 25 additions and 8 deletions

View file

@ -175,10 +175,10 @@ class UMEClient:
return headers
def _client(self) -> httpx.Client:
# Force HTTP/1.1 (disable HTTP/2) due to UME server compatibility issues.
# httpx defaults to HTTP/1.1 unless http2=True, but some environments still
# negotiate/behave unexpectedly; be explicit here.
return httpx.Client(verify=self.verify_tls, timeout=self.timeout_s, http2=False)
# Use explicit HTTPTransport to keep behavior consistent with onsite validation.
# In this mode, requests run over HTTP/1.1 and avoid HTTP/2 negotiation issues.
transport = httpx.HTTPTransport()
return httpx.Client(verify=self.verify_tls, timeout=self.timeout_s, transport=transport)
def _extract_token_and_ttl(self, payload: dict[str, Any]) -> tuple[str, int | None]:
token = ""