From e53c407a9c4d374fff8286810cca83c73367ec78 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 12 Sep 2026 17:36:07 +0100 Subject: [PATCH 1/2] Document the HTTPX2 interception hook --- src/mock_vws/_httpx2_mock_server/decorators.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mock_vws/_httpx2_mock_server/decorators.py b/src/mock_vws/_httpx2_mock_server/decorators.py index 0f1eead37..08073400d 100644 --- a/src/mock_vws/_httpx2_mock_server/decorators.py +++ b/src/mock_vws/_httpx2_mock_server/decorators.py @@ -350,6 +350,9 @@ def start_httpx2_router( ), ) + # HTTPX2 has no public hook for intercepting clients created before the + # mock starts. RESPX patches the equivalent private HTTPX method: + # https://github.com/lundberg/respx/blob/57d8c29705fdbbaeb5cd216f1ea3bb0386d7ba16/respx/mocks.py#L150 # pylint: disable=protected-access original_sync = httpx2.Client._transport_for_url # noqa: SLF001 # pyright: ignore[reportPrivateUsage] original_async = httpx2.AsyncClient._transport_for_url # noqa: SLF001 # pyright: ignore[reportPrivateUsage] From e03db3651ec44c40e55dc98fd980eb5916a230a0 Mon Sep 17 00:00:00 2001 From: Adam Dangoor Date: Sat, 12 Sep 2026 18:32:23 +0100 Subject: [PATCH 2/2] Link the public middleware proposal --- src/mock_vws/_httpx2_mock_server/decorators.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/mock_vws/_httpx2_mock_server/decorators.py b/src/mock_vws/_httpx2_mock_server/decorators.py index 08073400d..8de7aa9a1 100644 --- a/src/mock_vws/_httpx2_mock_server/decorators.py +++ b/src/mock_vws/_httpx2_mock_server/decorators.py @@ -351,7 +351,9 @@ def start_httpx2_router( ) # HTTPX2 has no public hook for intercepting clients created before the - # mock starts. RESPX patches the equivalent private HTTPX method: + # mock starts. A public client extension API was proposed but closed as + # out of scope: https://github.com/pydantic/httpx2/issues/121 + # RESPX patches the equivalent private HTTPX method: # https://github.com/lundberg/respx/blob/57d8c29705fdbbaeb5cd216f1ea3bb0386d7ba16/respx/mocks.py#L150 # pylint: disable=protected-access original_sync = httpx2.Client._transport_for_url # noqa: SLF001 # pyright: ignore[reportPrivateUsage]