|
22 | 22 | from .cos_threadpool import SimpleThreadPool |
23 | 23 | from .cos_exception import CosClientError |
24 | 24 | from .cos_exception import CosServiceError |
| 25 | +from .version import __version__ |
25 | 26 |
|
26 | 27 | logger = logging.getLogger(__name__) |
27 | 28 |
|
@@ -192,7 +193,7 @@ def send_request(self, method, url, bucket, timeout=30, **kwargs): |
192 | 193 | """封装request库发起http请求""" |
193 | 194 | if self._conf._timeout is not None: # 用户自定义超时时间 |
194 | 195 | timeout = self._conf._timeout |
195 | | - kwargs['headers']['User-Agent'] = 'cos-python-sdk-v5.1.6.1' |
| 196 | + kwargs['headers']['User-Agent'] = 'cos-python-sdk-v' + __version__ |
196 | 197 | if self._conf._token is not None: |
197 | 198 | kwargs['headers']['x-cos-security-token'] = self._conf._token |
198 | 199 | if bucket is not None: |
@@ -281,7 +282,7 @@ def put_object(self, Bucket, Body, Key, EnableMD5=False, **kwargs): |
281 | 282 | data=Body, |
282 | 283 | headers=headers) |
283 | 284 |
|
284 | | - response = rt.headers |
| 285 | + response = dict(**rt.headers) |
285 | 286 | return response |
286 | 287 |
|
287 | 288 | def get_object(self, Bucket, Key, **kwargs): |
@@ -332,7 +333,7 @@ def get_object(self, Bucket, Key, **kwargs): |
332 | 333 | params=params, |
333 | 334 | headers=headers) |
334 | 335 |
|
335 | | - response = rt.headers |
| 336 | + response = dict(**rt.headers) |
336 | 337 | response['Body'] = StreamBody(rt) |
337 | 338 |
|
338 | 339 | return response |
@@ -422,7 +423,7 @@ def delete_object(self, Bucket, Key, **kwargs): |
422 | 423 | auth=CosS3Auth(self._conf._secret_id, self._conf._secret_key, Key), |
423 | 424 | headers=headers, |
424 | 425 | params=params) |
425 | | - data = rt.headers |
| 426 | + data = dict(**rt.headers) |
426 | 427 | return data |
427 | 428 |
|
428 | 429 | def delete_objects(self, Bucket, Delete={}, **kwargs): |
@@ -511,7 +512,7 @@ def head_object(self, Bucket, Key, **kwargs): |
511 | 512 | auth=CosS3Auth(self._conf._secret_id, self._conf._secret_key, Key, params=params), |
512 | 513 | headers=headers, |
513 | 514 | params=params) |
514 | | - return rt.headers |
| 515 | + return dict(**rt.headers) |
515 | 516 |
|
516 | 517 | def copy_object(self, Bucket, Key, CopySource, CopyStatus='Copy', **kwargs): |
517 | 518 | """文件拷贝,文件信息修改 |
@@ -554,7 +555,7 @@ def copy_object(self, Bucket, Key, CopySource, CopyStatus='Copy', **kwargs): |
554 | 555 | if 'ETag' not in body: |
555 | 556 | logger.error(rt.content) |
556 | 557 | raise CosServiceError('PUT', rt.content, 200) |
557 | | - data = rt.headers |
| 558 | + data = dict(**rt.headers) |
558 | 559 | data.update(body) |
559 | 560 | return data |
560 | 561 |
|
@@ -601,7 +602,7 @@ def upload_part_copy(self, Bucket, Key, PartNumber, UploadId, CopySource, CopySo |
601 | 602 | params=params, |
602 | 603 | auth=CosS3Auth(self._conf._secret_id, self._conf._secret_key, Key, params=params)) |
603 | 604 | body = xml_to_dict(rt.content) |
604 | | - data = rt.headers |
| 605 | + data = dict(**rt.headers) |
605 | 606 | data.update(body) |
606 | 607 | return data |
607 | 608 |
|
@@ -734,7 +735,7 @@ def complete_multipart_upload(self, Bucket, Key, UploadId, MultipartUpload={}, * |
734 | 735 | if 'ETag' not in body: |
735 | 736 | logger.error(rt.content) |
736 | 737 | raise CosServiceError('POST', rt.content, 200) |
737 | | - data = rt.headers |
| 738 | + data = dict(**rt.headers) |
738 | 739 | data.update(body) |
739 | 740 | return data |
740 | 741 |
|
@@ -2530,7 +2531,7 @@ def append_object(self, Bucket, Key, Position, Data, **kwargs): |
2530 | 2531 | data=Data, |
2531 | 2532 | headers=headers, |
2532 | 2533 | params=params) |
2533 | | - response = rt.headers |
| 2534 | + response = dict(**rt.headers) |
2534 | 2535 | return response |
2535 | 2536 |
|
2536 | 2537 | def put_object_from_local_file(self, Bucket, LocalFilePath, Key, EnableMD5=False, **kwargs): |
|
0 commit comments