headers[quote(k)] = quote(v, safe='/=,:@ *"') if type(v) == types.StringType else v
return headers
-def _handle_response(response, verbose, debug):
+def _handle_response(response, verbose=False, debug=False):
headers = response.getheaders()
headers = dict((unquote(h), unquote(v)) for h,v in headers)
raise Fault(data, int(response.status))
#print '**', response.status, headers, data, '\n'
- return response.status, headers, data
\ No newline at end of file
+ return response.status, headers, data
+
+def authenticate(authentication_host, token):
+ con = HTTPConnection(authentication_host)
+ kwargs = {}
+ kwargs['headers'] = {}
+ kwargs['headers']['X-Auth-Token'] = token
+ kwargs['headers']['Content-Length'] = 0
+
+ path = '/im/authenticate'
+ con.request('GET', path, **kwargs)
+ response = con.getresponse()
+ return _handle_response(response)
\ No newline at end of file