Skip to content
Open
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
Original file line number Diff line number Diff line change
@@ -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."
}
1 change: 1 addition & 0 deletions packages/smithy-http/src/smithy_http/aio/aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
14 changes: 14 additions & 0 deletions packages/smithy-http/tests/unit/aio/test_aiohttp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Loading