From 37f0bd9c2bfef40704267b34997eb92b22c1012b Mon Sep 17 00:00:00 2001 From: Mark Zhitomirski Date: Sat, 25 Oct 2025 00:56:01 +0400 Subject: [PATCH] Fix aiohttp ClientResponseError on twitter.com aiohttp.client_exceptions.ClientResponseError: 400, message='Got more than 8190 bytes (10627) when reading Header value is too long.', url='https://twitter.com/' --- understanding-asynchronous-programming/example_6.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/understanding-asynchronous-programming/example_6.py b/understanding-asynchronous-programming/example_6.py index 1f4e3d2810..792decee4d 100644 --- a/understanding-asynchronous-programming/example_6.py +++ b/understanding-asynchronous-programming/example_6.py @@ -6,7 +6,8 @@ async def task(name, work_queue): timer = Timer(text=f"Task {name} elapsed time: {{:.1f}}") - async with aiohttp.ClientSession() as session: + # default max_field_size=8190 is too low for Twitter's content-security-policy Header + async with aiohttp.ClientSession(max_field_size=16380) as session: while not work_queue.empty(): url = await work_queue.get() print(f"Task {name} getting URL: {url}")