(self, proxy_url: str | None = None)
| 76 | ) |
| 77 | |
| 78 | def _make_client(self, proxy_url: str | None = None) -> httpx.AsyncClient: |
| 79 | if proxy_url: |
| 80 | if proxy_url.startswith("https:") and not self._verify_certificates: |
| 81 | proxy_ssl_context = _make_insecure_ssl_ctx() |
| 82 | else: |
| 83 | proxy_ssl_context = None |
| 84 | proxy = httpx.Proxy(proxy_url, ssl_context=proxy_ssl_context) |
| 85 | else: |
| 86 | proxy = None |
| 87 | |
| 88 | client = httpx.AsyncClient( |
| 89 | cookies=NullCookieJar(), |
| 90 | transport=httpx.AsyncHTTPTransport( |
| 91 | verify=self._ssl_context, |
| 92 | local_address=self._bind_host, |
| 93 | limits=self._limits, |
| 94 | trust_env=False, |
| 95 | proxy=proxy, |
| 96 | ), |
| 97 | ) |
| 98 | # https://github.com/encode/httpx/discussions/1566 |
| 99 | for header_name in ("accept", "accept-encoding", "user-agent"): |
| 100 | client.headers.pop(header_name, None) |
| 101 | return client |
| 102 | |
| 103 | def _get_client(self, proxy_url: str | None) -> httpx.AsyncClient: |
| 104 | if proxy_url is None: |
no test coverage detected