From ea8d82cf0da06c4ed4ec8971af679677cdbe38a1 Mon Sep 17 00:00:00 2001 From: Andrey Kislyuk Date: Tue, 19 Sep 2017 09:54:46 -0700 Subject: [PATCH] HTTPSignatureAuth.verify: Rely only on request.url, not path_url This allows broader compatibility with request objects: in addition to requests.PreparedRequest, we can now support requests.Request or any object that has the method, url, and headers attributes. --- requests_http_signature/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/requests_http_signature/__init__.py b/requests_http_signature/__init__.py index e14ce80..a61e67c 100644 --- a/requests_http_signature/__init__.py +++ b/requests_http_signature/__init__.py @@ -74,7 +74,8 @@ class HTTPSignatureAuth(requests.auth.AuthBase): sts = [] for header in headers: if header == "(request-target)": - sts.append("(request-target): {} {}".format(request.method.lower(), request.path_url)) + path_url = requests.models.RequestEncodingMixin.path_url.fget(request) + sts.append("(request-target): {} {}".format(request.method.lower(), path_url)) else: if header.lower() == "host": value = request.headers.get("host", urlparse(request.url).hostname)