@@ -44,7 +44,7 @@ def __init__(self, Appid=None, Region=None, SecretId=None, SecretKey=None, Token
4444 Access_id = None , Access_key = None , Secret_id = None , Secret_key = None , Endpoint = None , IP = None , Port = None ,
4545 Anonymous = None , UA = None , Proxies = None , Domain = None , ServiceDomain = None , KeepAlive = True , PoolConnections = 10 ,
4646 PoolMaxSize = 10 , AllowRedirects = False , SignHost = True , EndpointCi = None , EndpointPic = None , EnableOldDomain = True , EnableInternalDomain = True , SignParams = True ,
47- AutoSwitchDomainOnRetry = False ):
47+ AutoSwitchDomainOnRetry = False , VerifySSL = None ):
4848 """初始化,保存用户的信息
4949
5050 :param Appid(string): 用户APPID.
@@ -75,6 +75,8 @@ def __init__(self, Appid=None, Region=None, SecretId=None, SecretKey=None, Token
7575 :param EnableOldDomain(bool): 是否使用旧的myqcloud.com域名访问COS
7676 :param EnableInternalDomain(bool): 是否使用内网域名访问COS
7777 :param SignParams(bool): 是否将请求参数算入签名
78+ :param AutoSwitchDomainOnRetry(bool): 重试请求时是否将myqcloud.com域名切换为tencentcos.cn
79+ :param VerifySSL(bool): 是否开启SSL证书校验
7880 """
7981 self ._appid = to_unicode (Appid )
8082 self ._token = to_unicode (Token )
@@ -100,6 +102,7 @@ def __init__(self, Appid=None, Region=None, SecretId=None, SecretKey=None, Token
100102 self ._enable_internal_domain = EnableInternalDomain
101103 self ._sign_params = SignParams
102104 self ._auto_switch_domain_on_retry = AutoSwitchDomainOnRetry
105+ self ._verify_ssl = VerifySSL
103106
104107 if self ._domain is None :
105108 self ._endpoint = format_endpoint (Endpoint , Region , u'cos.' , EnableOldDomain , EnableInternalDomain )
@@ -379,7 +382,7 @@ def send_request(self, method, url, bucket=None, timeout=30, cos_request=True, c
379382 except Exception as ioe :
380383 file_position = None
381384 kwargs ['data' ] = to_bytes (kwargs ['data' ])
382- if self ._conf ._ip is not None and self ._conf ._scheme == 'https' :
385+ if self ._conf ._ip is not None and self ._conf ._scheme == 'https' or self . _conf . _verify_ssl is False :
383386 kwargs ['verify' ] = False
384387 if self ._conf ._allow_redirects is not None :
385388 kwargs ['allow_redirects' ] = self ._conf ._allow_redirects
@@ -392,6 +395,7 @@ def send_request(self, method, url, bucket=None, timeout=30, cos_request=True, c
392395 try :
393396 if j != 0 :
394397 if client_can_retry (file_position , ** kwargs ):
398+ kwargs ['headers' ]['x-cos-sdk-retry' ] = 'true' # SDK重试标记
395399 time .sleep (j )
396400 else :
397401 break
0 commit comments