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.
pull/4/head
Andrey Kislyuk 2017-09-19 09:54:46 -07:00
parent cd28a779b1
commit ea8d82cf0d
1 changed files with 2 additions and 1 deletions

View File

@ -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)