Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions aiohttp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,11 @@ 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,
Expand Down
7 changes: 7 additions & 0 deletions tests/test_client_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@
make_request("get", "http://python.org:123e/")


def test_hostname_err(make_request: _RequestMaker) -> None:

Check warning

Code scanning / CodeQL

Variable defined multiple times Warning test

This assignment to 'test_hostname_err' is unnecessary as it is
redefined
before this value is used.
with pytest.raises(ValueError):
make_request("get", "http://:8080/")

Expand Down Expand Up @@ -1570,3 +1570,10 @@
).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")
Loading