diff options
Diffstat (limited to 'bonafide/src/leap/bonafide/_http.py')
-rw-r--r-- | bonafide/src/leap/bonafide/_http.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/bonafide/src/leap/bonafide/_http.py b/bonafide/src/leap/bonafide/_http.py index 6510e84..39aabab 100644 --- a/bonafide/src/leap/bonafide/_http.py +++ b/bonafide/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('') |