Request doesn't provide a way to refresh headers for each retry, making it impossible to regenerate expired Authorization headers

Aperta
#5,975 10 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
api, networking

Direzione di ricerca

Inizia tracciando i tentativi attraverso requests.adapters.HTTPAdapter e urllib3.util.retry.Retry, quindi confronta questo flusso con AuthBase.call nell’implementazione edgegrid.py collegata. Verifica se ogni tentativo richiama nuovamente l’autenticazione; il lavoro è completato quando gli header Authorization scaduti possono essere rigenerati per ogni tentativo e il comportamento è documentato o coperto da un test appropriato.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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?

Lingua principale
Python
Stelle
54.7k
Fork
10.8k
Merge medio
18m
PR unite (30g)
1

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di psf/requests

Tutte le issue di psf/requests

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.