2424from urllib3 .util .retry import Retry
2525
2626import requests
27- from requests .adapters import HTTPAdapter
2827from requests .structures import CaseInsensitiveDict
2928
3029from ibm_cloud_sdk_core .authenticators import Authenticator
3130from .api_exception import ApiException
3231from .detailed_response import DetailedResponse
3332from .token_managers .token_manager import TokenManager
3433from .utils import (has_bad_first_or_last_char , remove_null_values ,
35- cleanup_values , read_external_sources , strip_extra_slashes )
34+ cleanup_values , read_external_sources , strip_extra_slashes ,
35+ SSLHTTPAdapter )
3636from .version import __version__
3737
3838# Uncomment this to enable http debugging
@@ -94,12 +94,15 @@ def __init__(self,
9494 self .enable_gzip_compression = enable_gzip_compression
9595 self ._set_user_agent_header (self ._build_user_agent ())
9696 self .retry_config = None
97- self .http_adapter = HTTPAdapter ()
97+ self .http_adapter = SSLHTTPAdapter ()
9898 if not self .authenticator :
9999 raise ValueError ('authenticator must be provided' )
100100 if not isinstance (self .authenticator , Authenticator ):
101101 raise ValueError ('authenticator should be of type Authenticator' )
102102
103+ self .http_client .mount ('http://' , self .http_adapter )
104+ self .http_client .mount ('https://' , self .http_adapter )
105+
103106 def enable_retries (self , max_retries : int = 4 , retry_interval : float = 1.0 ) -> None :
104107 """Enable automatic retries on the underlying http client used by the BaseService instance.
105108
@@ -121,14 +124,14 @@ def enable_retries(self, max_retries: int = 4, retry_interval: float = 1.0) -> N
121124 allowed_methods = ['HEAD' , 'GET' , 'PUT' ,
122125 'DELETE' , 'OPTIONS' , 'TRACE' , 'POST' ]
123126 )
124- self .http_adapter = HTTPAdapter (max_retries = self .retry_config )
127+ self .http_adapter = SSLHTTPAdapter (max_retries = self .retry_config )
125128 self .http_client .mount ('http://' , self .http_adapter )
126129 self .http_client .mount ('https://' , self .http_adapter )
127130
128131 def disable_retries (self ):
129132 """Remove retry config from http_adapter"""
130133 self .retry_config = None
131- self .http_adapter = HTTPAdapter ()
134+ self .http_adapter = SSLHTTPAdapter ()
132135 self .http_client .mount ('http://' , self .http_adapter )
133136 self .http_client .mount ('https://' , self .http_adapter )
134137
0 commit comments