From 87e09596a0c5905cf55f4d46cce50210ee52d65a Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 19 Dec 2025 20:27:17 +0000 Subject: [PATCH 1/2] fix: use .read() instead of .content.read() in aiohttp transport Using .read() is more robust when working with caching libraries like aiohttp-client-cache, which may cause .content.read() to return empty bytes on subsequent reads. .read() ensures the full body is returned. Fixes #1248 --- google/auth/transport/_aiohttp_requests.py | 2 +- tests_async/transport/test_aiohttp_requests.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/google/auth/transport/_aiohttp_requests.py b/google/auth/transport/_aiohttp_requests.py index 2465b6a97..ac1ebb320 100644 --- a/google/auth/transport/_aiohttp_requests.py +++ b/google/auth/transport/_aiohttp_requests.py @@ -79,7 +79,7 @@ def data(self): async def raw_content(self): if self._raw_content is None: - self._raw_content = await self._response.content.read() + self._raw_content = await self._response.read() return self._raw_content async def content(self): diff --git a/tests_async/transport/test_aiohttp_requests.py b/tests_async/transport/test_aiohttp_requests.py index 1c825aaa6..9ffe05bc7 100644 --- a/tests_async/transport/test_aiohttp_requests.py +++ b/tests_async/transport/test_aiohttp_requests.py @@ -40,7 +40,7 @@ def test__is_compressed_not(self): @pytest.mark.asyncio async def test_raw_content(self): mock_response = mock.AsyncMock() - mock_response.content.read.return_value = mock.sentinel.read + mock_response.read.return_value = mock.sentinel.read combined_response = aiohttp_requests._CombinedResponse(response=mock_response) raw_content = await combined_response.raw_content() assert raw_content == mock.sentinel.read @@ -53,7 +53,7 @@ async def test_raw_content(self): @pytest.mark.asyncio async def test_content(self): mock_response = mock.AsyncMock() - mock_response.content.read.return_value = mock.sentinel.read + mock_response.read.return_value = mock.sentinel.read combined_response = aiohttp_requests._CombinedResponse(response=mock_response) content = await combined_response.content() assert content == mock.sentinel.read From 9485c59a4b0d425537979d3bdd0d93aa97eda645 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Fri, 19 Dec 2025 20:59:55 +0000 Subject: [PATCH 2/2] fix: use .read() instead of .content.read() in aiohttp transport Using .read() is more robust when working with caching libraries like aiohttp-client-cache, which may cause .content.read() to return empty bytes on subsequent reads. .read() ensures the full body is returned. Fixes #1248