We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Yes, I would like to have the option to declare a base_url to a ClientSession, such that every request use the same base_url for that session.
base_url
Instead of writing:
async with aiohttp.ClientSession() as session: async with session.get('http://python.org') as response: print(await response.text()) async with session.get('http://python.org/foobar') as response: print(await response.text()) async with session.get('http://python.org/foo/foo/bar') as response: print(await response.text())
Write:
async with aiohttp.ClientSession(base_url='http://python.org') as session: async with session.get('/') as response: print(await response.text()) async with session.get('/foobar') as response: print(await response.text()) async with session.get('/foo/foo/bar') as response: print(await response.text())
Add an base_url parameter to ClientSession, like httpx does.
An alternative is having a constant BASE = 'http://python.org' and then say:
BASE = 'http://python.org'
async with session.get(f'{BASE}/foobar') as response: print(await response.text())
Client
No response
The text was updated successfully, but these errors were encountered:
ClientSession
Successfully merging a pull request may close this issue.
Is your feature request related to a problem?
Yes, I would like to have the option to declare a
base_url
to a ClientSession, such that every request use the samebase_url
for that session.Instead of writing:
Write:
Describe the solution you'd like
Add an
base_url
parameter to ClientSession, like httpx does.Describe alternatives you've considered
An alternative is having a constant
BASE = 'http://python.org'
and then say:Related component
Client
Additional context
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: