Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
Sign headers would update the dictionary in place
Browse files Browse the repository at this point in the history
Changed so that it calls dict.update correctly from the returned auth
dict
  • Loading branch information
David Sutton committed Jun 12, 2014
1 parent ef35fb3 commit f92a4aa
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions http_signature/requests_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,17 @@ def __init__(self, key_id='', secret='', algorithm='rsa-sha256',
headers=None, allow_agent=False):
headers = headers or []
self.header_signer = HeaderSigner(key_id=key_id, secret=secret,
algorithm=algorithm, headers=headers, allow_agent=allow_agent)
algorithm=algorithm, headers=headers)
self.uses_host = 'host' in [h.lower() for h in headers]

def __call__(self, r):
self.header_signer.sign_headers(
headers = self.header_signer.sign_headers(
r.headers,
# 'Host' header unavailable in request object at this point
# if 'host' header is needed, extract it from the url
host=urlparse(r.url).netloc if self.uses_host else None,
method=r.method,
path=r.path_url,
http_version='1.1')
r.headers.update(headers)
return r

0 comments on commit f92a4aa

Please sign in to comment.