Skip to content

Commit c0ca560

Browse files
authored
Merge pull request #82 from dt3310321/s3
add ua
2 parents 678d6fd + 572e98d commit c0ca560

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

qcloud_cos/cos_client.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class CosConfig(object):
3131
"""config类,保存用户相关信息"""
3232
def __init__(self, Appid=None, Region=None, SecretId=None, SecretKey=None, Token=None, Scheme=None, Timeout=None,
3333
Access_id=None, Access_key=None, Secret_id=None, Secret_key=None,
34-
Endpoint=None, IP=None, Port=None, Anonymous=None):
34+
Endpoint=None, IP=None, Port=None, Anonymous=None, UA=None):
3535
"""初始化,保存用户的信息
3636
3737
:param Appid(string): 用户APPID.
@@ -49,6 +49,7 @@ def __init__(self, Appid=None, Region=None, SecretId=None, SecretKey=None, Token
4949
:param IP(string): 访问COS的ip
5050
:param Port(int): 访问COS的port
5151
:param Anonymous(bool): 是否使用匿名访问COS
52+
:param UA(string): 使用自定义的UA来访问COS
5253
"""
5354
self._appid = to_unicode(Appid)
5455
self._token = to_unicode(Token)
@@ -58,6 +59,7 @@ def __init__(self, Appid=None, Region=None, SecretId=None, SecretKey=None, Token
5859
self._ip = to_unicode(IP)
5960
self._port = Port
6061
self._anonymous = Anonymous
62+
self._ua = UA
6163

6264
if Scheme is None:
6365
Scheme = u'https'
@@ -196,7 +198,10 @@ def send_request(self, method, url, bucket, timeout=30, **kwargs):
196198
"""封装request库发起http请求"""
197199
if self._conf._timeout is not None: # 用户自定义超时时间
198200
timeout = self._conf._timeout
199-
kwargs['headers']['User-Agent'] = 'cos-python-sdk-v' + __version__
201+
if self._conf._ua is not None:
202+
kwargs['headers']['User-Agent'] = self._conf._ua
203+
else:
204+
kwargs['headers']['User-Agent'] = 'cos-python-sdk-v' + __version__
200205
if self._conf._token is not None:
201206
kwargs['headers']['x-cos-security-token'] = self._conf._token
202207
if bucket is not None:

qcloud_cos/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11

2-
__version__ = '5.1.6.4'
2+
__version__ = '5.1.6.5'

0 commit comments

Comments
 (0)