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

Change headers between requests #48

Closed
vToMy opened this issue Aug 22, 2021 · 4 comments
Closed

Change headers between requests #48

vToMy opened this issue Aug 22, 2021 · 4 comments

Comments

@vToMy
Copy link

vToMy commented Aug 22, 2021

I use jwt in header to authenticate as client. However after some retries the token expires and retrying will fail unless I update the token.
Is it possible to add changing headers on retrying?
I think being able to alter the request object itself would be the most flexable solution.

@dnovmp
Copy link

dnovmp commented Aug 6, 2022

+1
I second it.

@inyutin
Copy link
Owner

inyutin commented Aug 7, 2022

@vToMy @dnovmp I'm working on it. I'm planning you would be able to pass requests list, as currently you can pass list of urls. I will present this soon

@inyutin
Copy link
Owner

inyutin commented Aug 11, 2022

@dnovmp @vToMy
You can do it now! Update to v2.8.0

@inyutin
Copy link
Owner

inyutin commented Aug 11, 2022

Example from readme:

from aiohttp_retry import RetryClient, RequestParams, ExponentialRetry

async def main():
    retry_client = RetryClient(raise_for_status=False)

    async with retry_client.requests(
        params_list=[
            RequestParams(
                method='GET',
                path='https://ya.ru',
            ),
            RequestParams(
                method='GET',
                path='https://ya.ru',
                headers={'some_header': 'some_value'},
            ),
        ]
    ) as response:
        print(response.status)
        
    await retry_client.close()

@inyutin inyutin closed this as completed Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants