fix: 避免无 cookie 时重复预热会话
This commit is contained in:
@@ -89,6 +89,25 @@ async def test_warmup_happens_before_first_fetch_and_is_reused():
|
||||
assert seen.count(TARGET) == 2
|
||||
|
||||
|
||||
async def test_successful_warmup_is_reused_when_upstream_sets_no_cookie():
|
||||
"""首页可能返回 200 但不下发 Akamai cookie,仍不得重复预热。"""
|
||||
seen: list[str] = []
|
||||
|
||||
def handler(request: httpx.Request) -> httpx.Response:
|
||||
seen.append(str(request.url))
|
||||
return httpx.Response(200, text=GOOD_PAGE)
|
||||
|
||||
session = await build_session(handler)
|
||||
try:
|
||||
await session.fetch_html(TARGET, mobile=False)
|
||||
await session.fetch_html(TARGET, mobile=False)
|
||||
finally:
|
||||
await session.close()
|
||||
|
||||
assert seen.count("https://www.rakuten.co.jp/") == 1
|
||||
assert seen.count(TARGET) == 2
|
||||
|
||||
|
||||
async def test_missing_state_marker_is_treated_as_blocked():
|
||||
def handler(request: httpx.Request) -> httpx.Response:
|
||||
return httpx.Response(200, text="<html>no state here</html>")
|
||||
|
||||
Reference in New Issue
Block a user