MCPcopy
hub / github.com/scrapy/scrapy / _make_client

Method _make_client

scrapy/core/downloader/handlers/_httpx.py:78–101  ·  view source on GitHub ↗
(self, proxy_url: str | None = None)

Source from the content-addressed store, hash-verified

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:

Callers 2

__init__Method · 0.95
_get_clientMethod · 0.95

Calls 3

_make_insecure_ssl_ctxFunction · 0.90
NullCookieJarClass · 0.90
popMethod · 0.45

Tested by

no test coverage detected