@@ -128,7 +128,12 @@ class HttpConnection(object):
128
128
def __init__ (self , base_url , cert_data , ** client_kwargs ):
129
129
self ._conn = None
130
130
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 )
132
137
if cert_data :
133
138
if ("cert_file" in cert_data and cert_data ["cert_file" ]) or (
134
139
"ca_certs" in cert_data and cert_data ["ca_certs" ]
@@ -157,17 +162,13 @@ def _init_connection(self):
157
162
cert_reqs = "CERT_NONE"
158
163
self ._connection_properties .update (self ._connection_properties .pop ("ca_cert_data" ))
159
164
160
- timeout = urllib3 .util .Timeout (connect = 4800 , read = 4800 )
161
- retries = urllib3 .util .Retry (connect = 50 , read = 50 , redirect = 50 )
162
165
if self .proxy :
163
166
if self .proxy .startswith ("socks" ):
164
167
LOGGER .info ("Initializing a SOCKS proxy." )
165
168
http = SOCKSProxyManager (
166
169
self .proxy ,
167
170
cert_reqs = cert_reqs ,
168
171
maxsize = 50 ,
169
- timeout = timeout ,
170
- retries = retries ,
171
172
** self ._connection_properties
172
173
)
173
174
else :
@@ -176,8 +177,6 @@ def _init_connection(self):
176
177
self .proxy ,
177
178
cert_reqs = cert_reqs ,
178
179
maxsize = 50 ,
179
- timeout = timeout ,
180
- retries = retries ,
181
180
** self ._connection_properties
182
181
)
183
182
else :
@@ -187,12 +186,11 @@ def _init_connection(self):
187
186
except KeyError :
188
187
pass
189
188
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
+ )
196
194
197
195
self ._conn = http .request
198
196
0 commit comments