Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClientSession TypeError: max_line_size and max_field_size args #7515

Closed
1 task done
fili opened this issue Aug 11, 2023 · 1 comment · Fixed by #8991
Closed
1 task done

ClientSession TypeError: max_line_size and max_field_size args #7515

fili opened this issue Aug 11, 2023 · 1 comment · Fixed by #8991
Labels

Comments

@fili
Copy link

fili commented Aug 11, 2023

Describe the bug

max_line_size and max_field_size args for ClientSession are returning TypeError.

To Reproduce

import aiohttp
import asyncio

async def fetch(client):
    async with client.get('http://python.org') as resp:
        assert resp.status == 200
        return await resp.text()

async def main():
    async with aiohttp.ClientSession(max_line_size=8190*2) as client:
        html = await fetch(client)
        print(html)

asyncio.run(main())

Used code snippet from documentation and added: max_line_size=8190*2 for this example.

Which returns:
TypeError: ClientSession.__init__() got an unexpected keyword argument 'max_line_size'

This also applied to max_field_size.

Despite the options being in the codebase:

max_line_size: int = 8190,

But it is also missing from the official documentation:
https://docs.aiohttp.org/en/stable/_modules/aiohttp/client.html#ClientSession
https://docs.aiohttp.org/en/stable/client_reference.html#aiohttp.ClientSession

Which suggests this also needs updating. I may be mistaken, but I looks like the tests when these args were added do not cover the client side.

Expected behavior

No TypeError, but being able to define a larger accepted max_line_size and max_field_size when reading response headers from other websites.

Logs/tracebacks

Traceback (most recent call last):
  File "/aiohttp_test/test.py", line 14, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.10/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
    return future.result()
  File "/aiohttp_test/test.py", line 10, in main
    async with aiohttp.ClientSession(max_line_size=8190*2) as client:
TypeError: ClientSession.__init__() got an unexpected keyword argument 'max_line_size'

Python Version

$ python --version
Python 3.10.12

aiohttp Version

$ python -m pip show aiohttp
Name: aiohttp
Version: 3.8.5
Summary: Async http client/server framework (asyncio)
Home-page: https://github.com/aio-libs/aiohttp
Author: 
Author-email: 
License: Apache 2
Location: /aiohttp_test/env/lib/python3.10/site-packages
Requires: aiosignal, async-timeout, attrs, charset-normalizer, frozenlist, multidict, yarl
Required-by:

multidict Version

$ python -m pip show multidict
Name: multidict
Version: 6.0.4
Summary: multidict implementation
Home-page: https://github.com/aio-libs/multidict
Author: Andrew Svetlov
Author-email: andrew.svetlov@gmail.com
License: Apache 2
Location: /aiohttp_test/env/lib/python3.10/site-packages
Requires: 
Required-by: aiohttp, yarl

yarl Version

$ python -m pip show yarl
Name: yarl
Version: 1.9.2
Summary: Yet another URL library
Home-page: https://github.com/aio-libs/yarl/
Author: Andrew Svetlov
Author-email: andrew.svetlov@gmail.com
License: Apache-2.0
Location: /aiohttp_test/env/lib/python3.10/site-packages
Requires: idna, multidict
Required-by: aiohttp

OS

Linux firefly 5.19.0-50-generic #50-Ubuntu SMP PREEMPT_DYNAMIC Mon Jul 10 18:24:29 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

Related component

Client

Additional context

Trying to crawl a page which hits the max_line_size/max_field_size limit in their headers. As I can't up the number now due to this bug, I can't access the page (even though in Chrome I can)

Code of Conduct

  • I agree to follow the aio-libs Code of Conduct
@Dreamsorcerer
Copy link
Member

Seems to be working for me today. Judging by your description, you must have crawled through the code and then tried to use something that hadn't been released yet...

The docs still appear to need updating though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants