Request doesn't provide a way to refresh headers for each retry, making it impossible to regenerate expired Authorization headers
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 54.3k
- Forks
- 10.4k
- Avg merge
- 16h 43m
- Merged PRs (30d)
- 3
Description
I am using requests 2.23.0 with Python 3.8.
My app configures the requests.packages.urllib3.util.retry.Retry instance and then passes it via the max_retries arg to requests.adapters.HTTPAdapter constructor and then mounts the adapter as follows:
class RetriableSslSession(requests.Session):
def __init__(self):
super(RetriableSslSession, self).__init__()
self.mount('https://', create_default_ssl_adapter())
Then before making a request, my app sets session.auth to an instance of EdgeGridAuth that is derived from requests.auth.AuthBase.
Since EdgeGridAuth implements the AuthBase.__call__ method, I expected that the Authorization header would be generated for each retry. However, in our apache proxy logs, we're seeing the same Authorization header reused from time to time, which suggests that retries are not causing the Authorization header to be generated.
Could you please let me know what I may be doing wrong and explain how to cause the Authorization header to be re-generated for each Retry?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing retries through requests.adapters.HTTPAdapter and urllib3.util.retry.Retry, then compare that flow with AuthBase.call in the linked edgegrid.py implementation. Confirm whether each retry invokes authentication again; done means expired Authorization headers can be regenerated for every retry, with the behavior documented or covered by an appropriate test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100