1616# under the License.
1717
1818import logging
19- import os
2019import platform
21- import socket
2220import string
2321import warnings
2422from base64 import b64encode
2523from typing import Optional
2624from urllib import parse
2725
28- import certifi
2926import urllib3
3027
3128from selenium import __version__
@@ -139,12 +136,7 @@ class RemoteConnection:
139136 """
140137
141138 browser_name = None
142- _timeout = (
143- float (os .getenv ("GLOBAL_DEFAULT_TIMEOUT" , str (socket .getdefaulttimeout ())))
144- if os .getenv ("GLOBAL_DEFAULT_TIMEOUT" ) is not None
145- else socket .getdefaulttimeout ()
146- )
147- _ca_certs = os .getenv ("REQUESTS_CA_BUNDLE" ) if "REQUESTS_CA_BUNDLE" in os .environ else certifi .where ()
139+ _client_config : ClientConfig = None
148140
149141 system = platform .system ().lower ()
150142 if system == "darwin" :
@@ -161,7 +153,12 @@ def get_timeout(cls):
161153 Timeout value in seconds for all http requests made to the
162154 Remote Connection
163155 """
164- return None if cls ._timeout == socket ._GLOBAL_DEFAULT_TIMEOUT else cls ._timeout
156+ warnings .warn (
157+ "get_timeout is deprecated, get timeout from ClientConfig instance instead" ,
158+ DeprecationWarning ,
159+ stacklevel = 2 ,
160+ )
161+ return cls ._client_config .timeout
165162
166163 @classmethod
167164 def set_timeout (cls , timeout ):
@@ -170,12 +167,22 @@ def set_timeout(cls, timeout):
170167 :Args:
171168 - timeout - timeout value for http requests in seconds
172169 """
173- cls ._timeout = timeout
170+ warnings .warn (
171+ "set_timeout is deprecated, set timeout in ClientConfig instance instead" ,
172+ DeprecationWarning ,
173+ stacklevel = 2 ,
174+ )
175+ cls ._client_config .timeout = timeout
174176
175177 @classmethod
176178 def reset_timeout (cls ):
177179 """Reset the http request timeout to socket._GLOBAL_DEFAULT_TIMEOUT."""
178- cls ._timeout = socket ._GLOBAL_DEFAULT_TIMEOUT
180+ warnings .warn (
181+ "reset_timeout is deprecated, use reset_timeout in ClientConfig instance instead" ,
182+ DeprecationWarning ,
183+ stacklevel = 2 ,
184+ )
185+ cls ._client_config .reset_timeout ()
179186
180187 @classmethod
181188 def get_certificate_bundle_path (cls ):
@@ -185,7 +192,12 @@ def get_certificate_bundle_path(cls):
185192 command executor. Defaults to certifi.where() or
186193 REQUESTS_CA_BUNDLE env variable if set.
187194 """
188- return cls ._ca_certs
195+ warnings .warn (
196+ "get_certificate_bundle_path is deprecated, get certificate bundle path from ClientConfig instance instead" ,
197+ DeprecationWarning ,
198+ stacklevel = 2 ,
199+ )
200+ return cls ._client_config .ca_certs
189201
190202 @classmethod
191203 def set_certificate_bundle_path (cls , path ):
@@ -196,7 +208,12 @@ def set_certificate_bundle_path(cls, path):
196208 :Args:
197209 - path - path of a .pem encoded certificate chain.
198210 """
199- cls ._ca_certs = path
211+ warnings .warn (
212+ "set_certificate_bundle_path is deprecated, set certificate bundle path in ClientConfig instance instead" ,
213+ DeprecationWarning ,
214+ stacklevel = 2 ,
215+ )
216+ cls ._client_config .ca_certs = path
200217
201218 @classmethod
202219 def get_remote_connection_headers (cls , parsed_url , keep_alive = False ):
@@ -239,15 +256,17 @@ def _separate_http_proxy_auth(self):
239256 return proxy_without_auth , auth
240257
241258 def _get_connection_manager (self ):
242- pool_manager_init_args = {"timeout" : self .get_timeout ()}
243- pool_manager_init_args .update (self ._init_args_for_pool_manager .get ("init_args_for_pool_manager" , {}))
259+ pool_manager_init_args = {"timeout" : self ._client_config .timeout }
260+ pool_manager_init_args .update (
261+ self ._client_config .init_args_for_pool_manager .get ("init_args_for_pool_manager" , {})
262+ )
244263
245- if self ._ignore_certificates :
264+ if self ._client_config . ignore_certificates :
246265 pool_manager_init_args ["cert_reqs" ] = "CERT_NONE"
247266 urllib3 .disable_warnings (urllib3 .exceptions .InsecureRequestWarning )
248- elif self ._ca_certs :
267+ elif self ._client_config . ca_certs :
249268 pool_manager_init_args ["cert_reqs" ] = "CERT_REQUIRED"
250- pool_manager_init_args ["ca_certs" ] = self ._ca_certs
269+ pool_manager_init_args ["ca_certs" ] = self ._client_config . ca_certs
251270
252271 if self ._proxy_url :
253272 if self ._proxy_url .lower ().startswith ("sock" ):
@@ -270,18 +289,23 @@ def __init__(
270289 init_args_for_pool_manager : Optional [dict ] = None ,
271290 client_config : Optional [ClientConfig ] = None ,
272291 ):
273- self .keep_alive = keep_alive
274- self ._url = remote_server_addr
275- self ._ignore_certificates = ignore_certificates
276- self ._init_args_for_pool_manager = init_args_for_pool_manager or {}
277- self ._client_config = client_config or ClientConfig (remote_server_addr , keep_alive )
292+ self ._client_config = client_config or ClientConfig (
293+ remote_server_addr = remote_server_addr ,
294+ keep_alive = keep_alive ,
295+ ignore_certificates = ignore_certificates ,
296+ init_args_for_pool_manager = init_args_for_pool_manager ,
297+ )
298+ RemoteConnection ._client_config = self ._client_config
278299
279300 if remote_server_addr :
280301 warnings .warn (
281302 "setting remote_server_addr in RemoteConnection() is deprecated, set in ClientConfig instance instead" ,
282303 DeprecationWarning ,
283304 stacklevel = 2 ,
284305 )
306+ self ._url = remote_server_addr
307+ else :
308+ self ._url = self ._client_config .remote_server_addr
285309
286310 if not keep_alive :
287311 warnings .warn (
@@ -290,6 +314,20 @@ def __init__(
290314 stacklevel = 2 ,
291315 )
292316
317+ if ignore_certificates :
318+ warnings .warn (
319+ "setting ignore_certificates in RemoteConnection() is deprecated, set in ClientConfig instance instead" ,
320+ DeprecationWarning ,
321+ stacklevel = 2 ,
322+ )
323+
324+ if init_args_for_pool_manager :
325+ warnings .warn (
326+ "setting init_args_for_pool_manager in RemoteConnection() is deprecated, set in ClientConfig instance instead" ,
327+ DeprecationWarning ,
328+ stacklevel = 2 ,
329+ )
330+
293331 if ignore_proxy :
294332 warnings .warn (
295333 "setting ignore_proxy in RemoteConnection() is deprecated, set in ClientConfig instance instead" ,
0 commit comments