Skip to content

Commit

Permalink
Add regression test for #8395
Browse files Browse the repository at this point in the history
  • Loading branch information
ddeville committed May 1, 2024
1 parent 0ba6cf2 commit ce19168
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/test_client_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -3644,3 +3644,26 @@ async def handler(_: web.Request) -> web.Response:
session = await aiohttp_client(app, raise_for_status=None) # type: ignore[arg-type]

await session.get("/")


@pytest.mark.xfail(
reason="#8395 Error message regression for large headers in 3.9.4",
raises=AssertionError,
)
async def test_header_too_large_error(aiohttp_client: Any) -> None:
"""By default when not specifying `max_field_size` requests should fail with a 400 status code."""

async def handler(_: web.Request) -> web.Response:
return web.Response(headers={"VeryLargeHeader": "x" * 10000})

app = web.Application()
app.add_routes([web.get("/", handler)])
client = await aiohttp_client(app)

try:
await client.get("/")
except aiohttp.ClientResponseError as e:
assert e.status == 400
assert "Got more than 8190 bytes" in e.message
else:
raise AssertionError("Expected ClientResponseError")

Check warning on line 3669 in tests/test_client_functional.py

View check run for this annotation

Codecov / codecov/patch

tests/test_client_functional.py#L3669

Added line #L3669 was not covered by tests

0 comments on commit ce19168

Please sign in to comment.