mirror of
https://github.com/ThePhaseless/Byparr.git
synced 2026-09-24 14:20:08 +01:00
refactor: drop redundant navigator.userAgent evaluate
page.goto() returns None only for about:blank or a same-URL-different-hash
navigation, so page_request is always present for a real request and its
headers always carry the UA. The evaluate call was therefore unreachable
as a fallback and, once moved before navigation, silently became the
primary source instead.
Request headers are also the correct source: consumers replay them with
the clearance cookies, so the UA the server saw is the one to report.
This restores the ordering d3a828e established.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
1c2b2df90d
commit
652c234782
+3
-8
@@ -60,12 +60,6 @@ async def read_item(request: LinkRequest, dep: BrowserDep) -> LinkResponse:
|
||||
timer = TimeoutTimer(duration=request.max_timeout)
|
||||
request.url = request.url.replace('"', "").strip()
|
||||
|
||||
try:
|
||||
user_agent = await dep.page.evaluate("navigator.userAgent")
|
||||
except Exception:
|
||||
logger.warning("Could not determine User-Agent via page.evaluate")
|
||||
user_agent = None
|
||||
|
||||
await setup_routes(request, dep)
|
||||
|
||||
try:
|
||||
@@ -86,8 +80,9 @@ async def read_item(request: LinkRequest, dep: BrowserDep) -> LinkResponse:
|
||||
page_html=page_html,
|
||||
)
|
||||
|
||||
if user_agent is None:
|
||||
user_agent = page_request.request.headers.get("user-agent") if page_request else ""
|
||||
user_agent = (
|
||||
page_request.request.headers.get("user-agent") if page_request else ""
|
||||
)
|
||||
|
||||
return LinkResponse(
|
||||
message="Success",
|
||||
|
||||
Reference in New Issue
Block a user