Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Remove aiohttp header size by monkey patching HeadersParser
- # Solution for https://www.v2ex.com/t/762640
- from aiohttp.http_parser import HeadersParser
- def monkey_init(
- self,
- max_line_size: int = 8190,
- max_headers: int = 32768,
- max_field_size: int = 8190,
- ) -> None:
- self.max_line_size = max_line_size
- self.max_headers = max_headers
- # self.max_field_size = max_field_size
- self.max_field_size = 2 << 31
- HeadersParser.__init__ = monkey_init
- import asyncio
- from aiohttp import ClientSession
- async def main():
- async with ClientSession() as req:
- async with req.get("http://127.0.0.1:8080/") as r:
- print(await r.text())
- asyncio.run(main())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement