@@ -456,12 +456,9 @@ def _request(self, method, url, options):
456
456
for hook in self .request_hooks :
457
457
stack .enter_context (hook ())
458
458
459
- new_tls_config = self ._get_new_tls_config (url , new_options )
460
- if persist :
461
- session = self .session
462
- self ._mount_https_adapter (session , new_tls_config )
463
- else :
464
- session = self ._create_session (tls_config = new_tls_config )
459
+ session = self .session if persist else self ._create_session ()
460
+ if url .startswith ('https' ):
461
+ self ._mount_https_adapter (session , ChainMap (get_tls_config_from_options (new_options ), self .tls_config ))
465
462
request_method = getattr (session , method )
466
463
467
464
if self .auth_token_handler :
@@ -503,14 +500,9 @@ def make_request_aia_chasing(self, request_method, method, url, new_options, per
503
500
certs = self .fetch_intermediate_certs (hostname , port )
504
501
if not certs :
505
502
raise e
506
- new_ca_certs = {'tls_intermediate_ca_certs' : certs }
507
- new_tls_config = self .tls_config .copy ()
508
- new_tls_config .update (new_ca_certs )
509
- if not persist :
510
- session = self ._create_session (new_tls_config )
511
- else :
512
- session = self .session
513
- self ._mount_https_adapter (session , new_tls_config )
503
+ session = self .session if persist else self ._create_session ()
504
+ if parsed_url .scheme == "https" :
505
+ self ._mount_https_adapter (session , ChainMap ({'tls_intermediate_ca_certs' : certs }, self .tls_config ))
514
506
request_method = getattr (session , method )
515
507
response = request_method (url , ** new_options )
516
508
return response
0 commit comments