Skip to content

Commit

Permalink
Fix connecting to unix:// urls
Browse files Browse the repository at this point in the history
fixes #8600
  • Loading branch information
bdraco committed Aug 7, 2024
1 parent c99a1e2 commit 53d2b3e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion aiohttp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ class ClientTimeout:
IDEMPOTENT_METHODS = frozenset({"GET", "HEAD", "OPTIONS", "TRACE", "PUT", "DELETE"})
HTTP_SCHEMA_SET = frozenset({"http", "https", ""})
WS_SCHEMA_SET = frozenset({"ws", "wss"})
ALLOWED_PROTOCOL_SCHEMA_SET = HTTP_SCHEMA_SET | WS_SCHEMA_SET
PROTOCOL_SCHEMA_SET = frozenset({"unix"})
ALLOWED_PROTOCOL_SCHEMA_SET = HTTP_SCHEMA_SET | WS_SCHEMA_SET | PROTOCOL_SCHEMA_SET

_RetType = TypeVar("_RetType")
_CharsetResolver = Callable[[ClientResponse, bytes], str]
Expand Down
6 changes: 3 additions & 3 deletions tests/test_client_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ async def create_connection(req, traces, timeout):
c.__del__()


@pytest.mark.parametrize("protocol", ["http", "https", "ws", "wss"])
@pytest.mark.parametrize("protocol", ["http", "https", "ws", "wss", "unix"])
async def test_ws_connect_allowed_protocols(
create_session: Any,
create_mocked_conn: Any,
Expand All @@ -482,7 +482,7 @@ async def test_ws_connect_allowed_protocols(
hdrs.CONNECTION: "upgrade",
hdrs.SEC_WEBSOCKET_ACCEPT: ws_key,
}
resp.url = URL(f"{protocol}://example.com")
resp.url = URL(f"{protocol}://example")
resp.cookies = SimpleCookie()
resp.start = mock.AsyncMock()

Expand Down Expand Up @@ -510,7 +510,7 @@ async def create_connection(req, traces, timeout):
"aiohttp.client.os"
) as m_os:
m_os.urandom.return_value = key_data
await session.ws_connect(f"{protocol}://example.com")
await session.ws_connect(f"{protocol}://example")

# normally called during garbage collection. triggers an exception
# if the connection wasn't already closed
Expand Down

0 comments on commit 53d2b3e

Please sign in to comment.