diff --git a/packages/smithy-http/.changes/next-release/smithy-http-enhancement-aa179eb92d72443d8a7664d7a1a07a38.json b/packages/smithy-http/.changes/next-release/smithy-http-enhancement-aa179eb92d72443d8a7664d7a1a07a38.json new file mode 100644 index 000000000..59e5156f1 --- /dev/null +++ b/packages/smithy-http/.changes/next-release/smithy-http-enhancement-aa179eb92d72443d8a7664d7a1a07a38.json @@ -0,0 +1,4 @@ +{ + "type": "enhancement", + "description": "Disabled automatic redirects in `AIOHTTPClient` so that redirect responses are returned to the caller instead of being followed transparently." +} diff --git a/packages/smithy-http/src/smithy_http/aio/aiohttp.py b/packages/smithy-http/src/smithy_http/aio/aiohttp.py index c5f08a1b4..294ad4b2f 100644 --- a/packages/smithy-http/src/smithy_http/aio/aiohttp.py +++ b/packages/smithy-http/src/smithy_http/aio/aiohttp.py @@ -108,6 +108,7 @@ async def send( params=parse_qs(request.destination.query), # type: ignore headers=headers_list, data=body, + allow_redirects=False, ) as resp: return await self._marshal_response(resp) diff --git a/packages/smithy-http/tests/unit/aio/test_aiohttp.py b/packages/smithy-http/tests/unit/aio/test_aiohttp.py index 4f4548faf..72c69ff32 100644 --- a/packages/smithy-http/tests/unit/aio/test_aiohttp.py +++ b/packages/smithy-http/tests/unit/aio/test_aiohttp.py @@ -51,6 +51,20 @@ async def test_send_preserves_explicitly_framed_empty_body() -> None: assert session.request.call_args.kwargs["data"] is body +async def test_send_disables_redirects() -> None: + client, session = _create_client() + request = HTTPRequest( + method="GET", + destination=URI(scheme="https", host="example.com", path="/"), + body=AsyncBytesReader(b""), + fields=Fields(), + ) + + await client.send(request) + + assert session.request.call_args.kwargs["allow_redirects"] is False + + async def test_prepare_body_preserves_nonempty_reader_position() -> None: client, _ = _create_client() body = AsyncBytesReader(b"request body")