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

オープン
#5,975 コメント 10 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
python
領域
api, networking

調査の方向性

まず requests.adapters.HTTPAdapter と urllib3.util.retry.Retry を通じた再試行を追跡し、次にリンク先の edgegrid.py 実装にある AuthBase.call とそのフローを比較します。再試行のたびに認証が再度呼び出されるか確認してください。期限切れの Authorization ヘッダーを再試行ごとに再生成でき、その動作が文書化されるか適切なテストでカバーされれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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?

主要言語
Python
スター
54.7k
フォーク
10.8k
平均マージ
18分
マージ済み PR(30日)
1

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

psf/requests のほかの issue

psf/requests の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。