feat: 为出站请求统一接入 HTTP 代理

This commit is contained in:
2026-08-14 16:08:39 +08:00
parent 3dc2aeb3a2
commit fabca9510d
23 changed files with 213 additions and 14 deletions
+5 -3
View File
@@ -24,7 +24,8 @@ sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
import httpx
from app.shared.config import get_settings
from app.shared.config import Settings, get_settings
from app.shared.proxy import httpx_client_options
from app.trading.core import auth_site
PROBE_DIR = Path(__file__).resolve().parent.parent / ".probe" / "checkout"
@@ -42,12 +43,13 @@ def load_cookies(state_path: Path) -> list[dict]:
return state.get("cookies", [])
def build_client(cookies: list[dict]) -> httpx.AsyncClient:
def build_client(cookies: list[dict], settings: Settings) -> httpx.AsyncClient:
client = httpx.AsyncClient(
headers=auth_site.PROFILES["rakuten"].headers(),
timeout=30.0,
follow_redirects=True,
http2=True,
**httpx_client_options(settings),
)
for cookie in cookies:
name = cookie.get("name")
@@ -210,7 +212,7 @@ async def main() -> int:
cookies = load_cookies(state_path)
print(f"加载 {len(cookies)} 条 cookie 自 {state_path}")
async with build_client(cookies) as client:
async with build_client(cookies, settings) as client:
await probe_readonly(client)
if args.mutate:
if not args.item_url: