From 6c770286c5ab8265b7f3bc5627055ce8c9d2927b Mon Sep 17 00:00:00 2001 From: SouthFox Date: Thu, 27 Jul 2023 15:53:45 +0800 Subject: [PATCH] [lint] fix arguments-renamed --- demo/httpsig.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/demo/httpsig.py b/demo/httpsig.py index 105ae99..5e3b22c 100644 --- a/demo/httpsig.py +++ b/demo/httpsig.py @@ -118,31 +118,32 @@ class HTTPXSigAuth(httpx.Auth): self.key = key def auth_flow( - self, r: httpx.Request + self, + request: httpx.Request ): bodydigest = None - if r.content: + if request.content: bh = hashlib.new("sha256") - bh.update(r.content) + bh.update(request.content) bodydigest = "SHA-256=" + base64.b64encode(bh.digest()).decode("utf-8") date = datetime.utcnow().strftime("%a, %d %b %Y %H:%M:%S GMT") - r.headers["Date"] = date + request.headers["Date"] = date sigheaders = {} if bodydigest: - r.headers["digest"] = bodydigest + request.headers["digest"] = bodydigest sigheaders = "(request-target) user-agent host date digest content-type" else: sigheaders = "(request-target) user-agent host date accept" - logger.warning(r.headers) + logger.warning(request.headers) sigdate = SignedData( - method = r.method, - path = r.url.path, + method = request.method, + path = request.url.path, signed_list = sigheaders.split(), body_digest = bodydigest, - headers = r.headers, + headers = request.headers, ) to_be_signed = HttpSignature.build_signature_string( @@ -162,5 +163,5 @@ class HTTPXSigAuth(httpx.Auth): sig_value = f'keyId="{key_id}",algorithm="rsa-sha256",\ headers="{sigheaders}",signature="{sig.decode()}"' logger.debug(f"signed request {sig_value=}") - r.headers["signature"] = sig_value - yield r + request.headers["signature"] = sig_value + yield request