| 77 | |
| 78 | |
| 79 | def _initialize_proxy_settings(): |
| 80 | stream_port_env = get_environment_variable("STREAM_PORT") |
| 81 | if stream_port_env == "0": |
| 82 | proxy_server_url = get_environment_variable( |
| 83 | "HTTPS_PROXY" |
| 84 | ) or get_environment_variable("HTTP_PROXY") |
| 85 | else: |
| 86 | proxy_server_url = f"http://127.0.0.1:{stream_port_env or 3120}/" |
| 87 | |
| 88 | if proxy_server_url: |
| 89 | state.PLAYWRIGHT_PROXY_SETTINGS = {"server": proxy_server_url} |
| 90 | if NO_PROXY_ENV: |
| 91 | state.PLAYWRIGHT_PROXY_SETTINGS["bypass"] = NO_PROXY_ENV.replace(",", ";") |
| 92 | state.logger.info( |
| 93 | f"Playwright proxy settings configured: {state.PLAYWRIGHT_PROXY_SETTINGS}" |
| 94 | ) |
| 95 | else: |
| 96 | state.logger.info("No proxy configured for Playwright.") |
| 97 | |
| 98 | |
| 99 | async def _start_stream_proxy(): |