@@ -128,7 +128,12 @@ class HttpConnection(object):
128128 def __init__ (self , base_url , cert_data , ** client_kwargs ):
129129 self ._conn = None
130130 self .base_url = base_url
131- self ._connection_properties = client_kwargs
131+ # Default values for connection properties
132+ self ._connection_properties = {
133+ 'timeout' : urllib3 .util .Timeout (connect = 4800 , read = 4800 ),
134+ 'retries' : urllib3 .util .Retry (connect = 50 , read = 50 , redirect = 50 ),
135+ }
136+ self ._connection_properties .update (client_kwargs )
132137 if cert_data :
133138 if ("cert_file" in cert_data and cert_data ["cert_file" ]) or (
134139 "ca_certs" in cert_data and cert_data ["ca_certs" ]
@@ -157,17 +162,13 @@ def _init_connection(self):
157162 cert_reqs = "CERT_NONE"
158163 self ._connection_properties .update (self ._connection_properties .pop ("ca_cert_data" ))
159164
160- timeout = urllib3 .util .Timeout (connect = 4800 , read = 4800 )
161- retries = urllib3 .util .Retry (connect = 50 , read = 50 , redirect = 50 )
162165 if self .proxy :
163166 if self .proxy .startswith ("socks" ):
164167 LOGGER .info ("Initializing a SOCKS proxy." )
165168 http = SOCKSProxyManager (
166169 self .proxy ,
167170 cert_reqs = cert_reqs ,
168171 maxsize = 50 ,
169- timeout = timeout ,
170- retries = retries ,
171172 ** self ._connection_properties
172173 )
173174 else :
@@ -176,8 +177,6 @@ def _init_connection(self):
176177 self .proxy ,
177178 cert_reqs = cert_reqs ,
178179 maxsize = 50 ,
179- timeout = timeout ,
180- retries = retries ,
181180 ** self ._connection_properties
182181 )
183182 else :
@@ -187,12 +186,11 @@ def _init_connection(self):
187186 except KeyError :
188187 pass
189188
190- if "timeout" not in self ._connection_properties :
191- http = PoolManager (
192- maxsize = 50 , cert_reqs = cert_reqs , timeout = timeout , retries = retries , ** self ._connection_properties
193- )
194- else :
195- http = PoolManager (cert_reqs = cert_reqs , maxsize = 50 , retries = retries , ** self ._connection_properties )
189+ http = PoolManager (
190+ cert_reqs = cert_reqs ,
191+ maxsize = 50 ,
192+ ** self ._connection_properties
193+ )
196194
197195 self ._conn = http .request
198196
0 commit comments