#NEWLINE# def _http_request( self , url , method , **kwargs ) : #NEWLINE# #INDENT# 'Send an http request with the specified characteristics.\n\n        Wrapper around requests.request to handle tasks such as\n        setting headers and error handling.\n        ' #NEWLINE# kwargs [ 'headers' ] = copy . deepcopy ( kwargs . get ( 'headers' , { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) ) #NEWLINE# kwargs [ 'headers' ] . setdefault ( 'User-Agent' , USER_AGENT ) #NEWLINE# if self . auth_token : #NEWLINE# #INDENT# kwargs [ 'headers' ] . setdefault ( 'X-Auth-Token' , self . auth_token ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# kwargs [ 'headers' ] . update ( self . credentials_headers ( ) ) #NEWLINE# #UNINDENT# if self . auth_url : #NEWLINE# #INDENT# kwargs [ 'headers' ] . setdefault ( 'X-Auth-Url' , self . auth_url ) #NEWLINE# #UNINDENT# if self . region_name : #NEWLINE# #INDENT# kwargs [ 'headers' ] . setdefault ( 'X-Region-Name' , self . region_name ) #NEWLINE# #UNINDENT# if ( self . include_pass and ( 'X-Auth-Key' not in kwargs [ 'headers' ] ) ) : #NEWLINE# #INDENT# kwargs [ 'headers' ] . update ( self . credentials_headers ( ) ) #NEWLINE# #UNINDENT# self . log_curl_request ( method , url , kwargs ) #NEWLINE# if ( self . cert_file and self . key_file ) : #NEWLINE# #INDENT# kwargs [ 'cert' ] = ( self . cert_file , self . key_file ) #NEWLINE# #UNINDENT# if ( self . verify_cert is not None ) : #NEWLINE# #INDENT# kwargs [ 'verify' ] = self . verify_cert #NEWLINE# #UNINDENT# allow_redirects = False #NEWLINE# timeout = None #NEWLINE# if ( method in [ 'POST' , 'DELETE' , 'PUT' , 'PATCH' ] ) : #NEWLINE# #INDENT# timeout = self . write_timeout #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( method is 'GET' ) : #NEWLINE# #INDENT# timeout = self . read_timeout #NEWLINE# #UNINDENT# #UNINDENT# resp = self . _make_request ( method , url , allow_redirects , timeout , ** kwargs ) #NEWLINE# if self . _unauthorized ( resp ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# self . re_authenticate ( ) #NEWLINE# kwargs [ 'headers' ] [ 'X-Auth-Token' ] = self . auth_token #NEWLINE# resp = self . _make_request ( method , url , allow_redirects , timeout , ** kwargs ) #NEWLINE# self . _check_status_code ( resp , method , ** kwargs ) #NEWLINE# #UNINDENT# except exc . KeystoneException as e : #NEWLINE# #INDENT# raise e #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# self . _check_status_code ( resp , method , ** kwargs ) #NEWLINE# #UNINDENT# return resp