@@ -91,6 +91,7 @@ def __init__(self, credential, endpoint, custom_key_values={}):
9191 self .requests_kwargs .update ({"json" : get_dku_key_values (key_value_body )})
9292 self .metadata = {}
9393 self .call_number = 0
94+ self .session = requests .Session ()
9495
9596 def set_login (self , credential ):
9697 login_type = credential .get ("login_type" , "no_auth" )
@@ -171,12 +172,12 @@ def request(self, method, url, can_raise_exeption=True, **kwargs):
171172 def request_with_redirect_retry (self , method , url , ** kwargs ):
172173 # In case of redirection to another domain, the authorization header is not kept
173174 # If redirect_auth_header is true, another attempt is made with initial headers to the redirected url
174- response = requests .request (method , url , ** kwargs )
175+ response = self . session .request (method , url , ** kwargs )
175176 if self .redirect_auth_header and not response .url .startswith (url ):
176177 redirection_kwargs = copy .deepcopy (kwargs )
177178 redirection_kwargs .pop ("params" , None ) # params are contained in the redirected url
178179 logger .warning ("Redirection ! Accessing endpoint {} with initial authorization headers" .format (response .url ))
179- response = requests .request (method , response .url , ** redirection_kwargs )
180+ response = self . session .request (method , response .url , ** redirection_kwargs )
180181 return response
181182
182183 def paginated_api_call (self , can_raise_exeption = True ):
0 commit comments