Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions qcloud_cos/cos_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self, Appid=None, Region=None, SecretId=None, SecretKey=None, Token
Access_id=None, Access_key=None, Secret_id=None, Secret_key=None, Endpoint=None, IP=None, Port=None,
Anonymous=None, UA=None, Proxies=None, Domain=None, ServiceDomain=None, KeepAlive=True, PoolConnections=10,
PoolMaxSize=10, AllowRedirects=False, SignHost=True, EndpointCi=None, EndpointPic=None, EnableOldDomain=True, EnableInternalDomain=True, SignParams=True,
AutoSwitchDomainOnRetry=False):
AutoSwitchDomainOnRetry=False, VerifySSL=None):
"""初始化,保存用户的信息

:param Appid(string): 用户APPID.
Expand Down Expand Up @@ -75,6 +75,8 @@ def __init__(self, Appid=None, Region=None, SecretId=None, SecretKey=None, Token
:param EnableOldDomain(bool): 是否使用旧的myqcloud.com域名访问COS
:param EnableInternalDomain(bool): 是否使用内网域名访问COS
:param SignParams(bool): 是否将请求参数算入签名
:param AutoSwitchDomainOnRetry(bool): 重试请求时是否将myqcloud.com域名切换为tencentcos.cn
:param VerifySSL(bool): 是否开启SSL证书校验
"""
self._appid = to_unicode(Appid)
self._token = to_unicode(Token)
Expand All @@ -100,6 +102,7 @@ def __init__(self, Appid=None, Region=None, SecretId=None, SecretKey=None, Token
self._enable_internal_domain = EnableInternalDomain
self._sign_params = SignParams
self._auto_switch_domain_on_retry = AutoSwitchDomainOnRetry
self._verify_ssl = VerifySSL

if self._domain is None:
self._endpoint = format_endpoint(Endpoint, Region, u'cos.', EnableOldDomain, EnableInternalDomain)
Expand Down Expand Up @@ -379,7 +382,7 @@ def send_request(self, method, url, bucket=None, timeout=30, cos_request=True, c
except Exception as ioe:
file_position = None
kwargs['data'] = to_bytes(kwargs['data'])
if self._conf._ip is not None and self._conf._scheme == 'https':
if self._conf._ip is not None and self._conf._scheme == 'https' or self._conf._verify_ssl is False:
kwargs['verify'] = False
if self._conf._allow_redirects is not None:
kwargs['allow_redirects'] = self._conf._allow_redirects
Expand All @@ -392,6 +395,7 @@ def send_request(self, method, url, bucket=None, timeout=30, cos_request=True, c
try:
if j != 0:
if client_can_retry(file_position, **kwargs):
kwargs['headers']['x-cos-sdk-retry'] = 'true' # SDK重试标记
time.sleep(j)
else:
break
Expand Down
10 changes: 7 additions & 3 deletions ut/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1831,9 +1831,14 @@ def test_post_bucket_inventory_configurations():
]
},
}
inventory_id = 'list1'
response = client.delete_bucket_inventory(
Bucket=test_bucket,
Id=inventory_id,
)
response = client.post_bucket_inventory(
Bucket=test_bucket,
Id='list1',
Id=inventory_id,
InventoryConfiguration=inventory_config,
)

Expand Down Expand Up @@ -1962,7 +1967,7 @@ def test_put_get_delete_bucket_referer():
response = client.get_bucket_referer(
Bucket=test_bucket,
)
assert len(response) == 0
assert response['RefererConfiguration'] is None


def test_put_get_traffic_limit():
Expand Down Expand Up @@ -5807,7 +5812,6 @@ def test_ci_asr_bucket():

if __name__ == "__main__":
setUp()
test_post_bucket_inventory_configurations()
"""
test_config_invalid_scheme()
test_config_credential_inst()
Expand Down