user defined browser header (#2752)

Co-authored-by: lawyzheng <lawyzheng1106@gmail.com>
This commit is contained in:
Shuchang Zheng
2025-06-19 00:42:34 -07:00
committed by GitHub
parent 2776475ca3
commit df5f40bdb9
15 changed files with 132 additions and 10 deletions

View File

@@ -31,6 +31,7 @@ class BrowserManager:
task_id: str | None = None,
workflow_run_id: str | None = None,
organization_id: str | None = None,
extra_http_headers: dict[str, str] | None = None,
) -> BrowserState:
pw = await async_playwright().start()
(
@@ -44,6 +45,7 @@ class BrowserManager:
task_id=task_id,
workflow_run_id=workflow_run_id,
organization_id=organization_id,
extra_http_headers=extra_http_headers,
)
return BrowserState(
pw=pw,
@@ -109,6 +111,7 @@ class BrowserManager:
url=task.url,
task_id=task.task_id,
organization_id=task.organization_id,
extra_http_headers=task.extra_http_headers,
)
self.pages[task.task_id] = browser_state
@@ -118,7 +121,11 @@ class BrowserManager:
# The URL here is only used when creating a new page, and not when using an existing page.
# This will make sure browser_state.page is not None.
await browser_state.get_or_create_page(
url=task.url, proxy_location=task.proxy_location, task_id=task.task_id, organization_id=task.organization_id
url=task.url,
proxy_location=task.proxy_location,
task_id=task.task_id,
organization_id=task.organization_id,
extra_http_headers=task.extra_http_headers,
)
return browser_state
@@ -173,6 +180,7 @@ class BrowserManager:
url=url,
workflow_run_id=workflow_run.workflow_run_id,
organization_id=workflow_run.organization_id,
extra_http_headers=workflow_run.extra_http_headers,
)
self.pages[workflow_run_id] = browser_state
@@ -186,6 +194,7 @@ class BrowserManager:
proxy_location=workflow_run.proxy_location,
workflow_run_id=workflow_run.workflow_run_id,
organization_id=workflow_run.organization_id,
extra_http_headers=workflow_run.extra_http_headers,
)
return browser_state