From 1f241abc0e451069e93473c791e41230bbf56d4f Mon Sep 17 00:00:00 2001 From: NewUserHa <32261870+NewUserHa@users.noreply.github.com> Date: Mon, 9 Dec 2024 03:53:30 +0800 Subject: [PATCH 1/3] Update client.py --- aiohttp/client.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/aiohttp/client.py b/aiohttp/client.py index bc6c0aaaa5d..1b7ee135112 100644 --- a/aiohttp/client.py +++ b/aiohttp/client.py @@ -611,6 +611,9 @@ async def _request( with suppress(LookupError): proxy, proxy_auth = get_env_proxy_for_url(url) + if proxy and not 'http' in proxy.scheme: + raise ValueError('aiohttp works with http(s) proxy only currently.') + req = self._request_class( method, url, From 59f00d9cd6b60c9345d5815fcbd184d57788e1a0 Mon Sep 17 00:00:00 2001 From: NewUserHa <32261870+NewUserHa@users.noreply.github.com> Date: Mon, 9 Dec 2024 04:11:04 +0800 Subject: [PATCH 2/3] Update test_client_request.py --- tests/test_client_request.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test_client_request.py b/tests/test_client_request.py index 1b5d3a88fff..b7b4ec06b35 100644 --- a/tests/test_client_request.py +++ b/tests/test_client_request.py @@ -1570,3 +1570,10 @@ def test_request_info_tuple_new() -> None: ).real_url is url ) + + +def test_hostname_err(make_request: _RequestMaker) -> None: + with pytest.raises(ValueError): + make_request("get", "http://python.org/", proxy="socks5://127.0.0.1:80") + with pytest.raises(ValueError): + make_request("get", "http://python.org/", proxy="socks5h://127.0.0.1:80") From d0babf5419bb71d94b0821e4af56fcb1fd9bcfae Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 8 Dec 2024 20:16:50 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- aiohttp/client.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/aiohttp/client.py b/aiohttp/client.py index 1b7ee135112..79d33d6128a 100644 --- a/aiohttp/client.py +++ b/aiohttp/client.py @@ -611,8 +611,10 @@ async def _request( with suppress(LookupError): proxy, proxy_auth = get_env_proxy_for_url(url) - if proxy and not 'http' in proxy.scheme: - raise ValueError('aiohttp works with http(s) proxy only currently.') + if proxy and not "http" in proxy.scheme: + raise ValueError( + "aiohttp works with http(s) proxy only currently." + ) req = self._request_class( method,