Skip to content

Commit

Permalink
Use bare string proxies parameter for httpx<0.28 (#17113)
Browse files Browse the repository at this point in the history
  • Loading branch information
AmberArr authored Dec 21, 2024
1 parent 80e4de7 commit 3f3d807
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions jupyterlab/extensions/pypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,26 @@ def make_connection(self, host):
_httpx_version = Version(httpx.__version__)
_httpx_client_args = {}

proxies = None
xmlrpc_transport_override = None

if http_proxy_url:
http_proxy = urlparse(http_proxy_url)
proxy_host, _, proxy_port = http_proxy.netloc.partition(":")

proxies = {
"http://": httpx.AsyncHTTPTransport(proxy=http_proxy_url),
"https://": httpx.AsyncHTTPTransport(proxy=https_proxy_url),
}

_httpx_client_args = {
("mounts" if _httpx_version >= Version("0.28.0") else "proxies"): proxies,
}
if _httpx_version >= Version("0.28.0"):
_httpx_client_args = {
"mounts": {
"http://": httpx.AsyncHTTPTransport(proxy=http_proxy_url),
"https://": httpx.AsyncHTTPTransport(proxy=https_proxy_url),
}
}
else:
_httpx_client_args = {
"proxies": {
"http://": http_proxy_url,
"https://": https_proxy_url,
}
}

xmlrpc_transport_override = ProxiedTransport()
xmlrpc_transport_override.set_proxy(proxy_host, proxy_port)
Expand Down

0 comments on commit 3f3d807

Please sign in to comment.