Skip to content
Merged
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
1 change: 1 addition & 0 deletions CHANGES/10959.feature.rst
2 changes: 1 addition & 1 deletion aiohttp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ def __init__(
max_line_size: int = 8190,
max_field_size: int = 8190,
fallback_charset_resolver: _CharsetResolver = lambda r, b: "utf-8",
middlewares: Optional[Sequence[ClientMiddlewareType]] = None,
middlewares: Sequence[ClientMiddlewareType] = (),
) -> None:
# We initialise _connector to None immediately, as it's referenced in __del__()
# and could cause issues if an exception occurs during initialisation.
Expand Down
4 changes: 2 additions & 2 deletions docs/client_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ The client session supports the context manager protocol for self closing.
trust_env=False, \
requote_redirect_url=True, \
trace_configs=None, \
middlewares=None, \
middlewares=(), \
read_bufsize=2**16, \
max_line_size=8190, \
max_field_size=8190, \
Expand Down Expand Up @@ -216,7 +216,7 @@ The client session supports the context manager protocol for self closing.

:param middlewares: A sequence of middleware instances to apply to all session requests.
Each middleware must match the :type:`ClientMiddlewareType` signature.
``None`` (default) is used when no middleware is needed.
``()`` (empty tuple, default) is used when no middleware is needed.
See :ref:`aiohttp-client-middleware` for more information.

.. versionadded:: 3.12
Expand Down
2 changes: 2 additions & 0 deletions tests/test_client_middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,8 @@ async def blocking_middleware(
# Check that no connections were leaked
assert len(connector._conns) == 0

await connector.close()


async def test_client_middleware_blocks_connection_without_dns_lookup(
aiohttp_server: AiohttpServer,
Expand Down
3 changes: 3 additions & 0 deletions tests/test_proxy_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ async def test_proxy_http_acquired_cleanup(
assert 0 == len(conn._acquired)

await sess.close()
await conn.close()


@pytest.mark.skip("we need to reconsider how we test this")
Expand All @@ -487,6 +488,7 @@ async def request() -> None:
assert 0 == len(conn._acquired)

await sess.close()
await conn.close()


@pytest.mark.skip("we need to reconsider how we test this")
Expand Down Expand Up @@ -521,6 +523,7 @@ async def request(pid: int) -> ClientResponse:
assert {resp.status for resp in responses} == {200}

await sess.close()
await conn.close()


@pytest.mark.xfail
Expand Down
1 change: 1 addition & 0 deletions tests/test_web_sendfile_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,7 @@ async def test_static_file_ssl(

resp.release()
await client.close()
await conn.close()


async def test_static_file_directory_traversal_attack(
Expand Down
Loading