diff options
author | Kali Kaneko <kali@leap.se> | 2015-09-04 02:18:51 -0400 |
---|---|---|
committer | Kali Kaneko <kali@leap.se> | 2015-09-04 02:18:51 -0400 |
commit | 6d73e628d47c65792a89c2cf2d4b9bf9b34901e0 (patch) | |
tree | b90fcfc10d1446991a53bb85c8f16fe8e8e97580 /src/leap/bonafide/_http.py | |
parent | 5728511e094aff3978c98fc1d616dce4b60a5a23 (diff) |
smtp certs [WIP]
Diffstat (limited to 'src/leap/bonafide/_http.py')
-rw-r--r-- | src/leap/bonafide/_http.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/leap/bonafide/_http.py b/src/leap/bonafide/_http.py index 6510e84..39aabab 100644 --- a/src/leap/bonafide/_http.py +++ b/src/leap/bonafide/_http.py @@ -18,6 +18,7 @@ """ twisted.web utils for bonafide. """ +import base64 import cookielib import urllib @@ -39,12 +40,15 @@ def cookieAgentFactory(verify_path, connectTimeout=30): return CookieAgent(agent, cookiejar) -def httpRequest(agent, url, values={}, headers={}, method='POST'): +def httpRequest(agent, url, values={}, headers={}, method='POST', token=None): data = '' if values: data = urllib.urlencode(values) headers['Content-Type'] = ['application/x-www-form-urlencoded'] + if token: + headers['Authorization'] = ['Token token="%s"' % (bytes(token))] + def handle_response(response): if response.code == 204: d = defer.succeed('') |