Skip to content

Commit e2712c1

Browse files
authored
Merge pull request #373 from qiniu/develop
Develop
2 parents 47f92c4 + 7fb86ba commit e2712c1

File tree

8 files changed

+57
-8
lines changed

8 files changed

+57
-8
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Changelog
2+
# 7.2.9(2020-08-06)
3+
*修改二进制对象上传python3 bug
4+
*修复获取域名列方法
5+
26
# 7.2.8(2020-03-27)
37
* add restoreAr
48

examples/get_domaininfo.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# -*- coding: utf-8 -*-
2+
# flake8: noqa
3+
4+
"""
5+
获取指定域名指定时间内的日志链接
6+
"""
7+
import qiniu
8+
from qiniu import DomainManager
9+
10+
11+
# 账户ak,sk
12+
access_key = ''
13+
secret_key = ''
14+
15+
auth = qiniu.Auth(access_key=access_key, secret_key=secret_key)
16+
domain_manager = DomainManager(auth)
17+
domain = ''
18+
ret, info = domain_manager.get_domain(domain)
19+
print(ret)
20+
print(info)

qiniu/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
# flake8: noqa
1111

12-
__version__ = '7.2.8'
12+
__version__ = '7.2.9'
1313

1414
from .auth import Auth, QiniuMacAuth
1515

qiniu/http.py

+15-3
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,20 @@ def _put(url, data, files, auth, headers=None):
7272
return __return_wrapper(r)
7373

7474

75-
def _get(url, params, auth):
75+
def _get(url, params, auth, headers=None):
7676
if _session is None:
7777
_init()
7878
try:
79+
post_headers = _headers.copy()
80+
if headers is not None:
81+
for k, v in headers.items():
82+
post_headers.update({k: v})
7983
r = _session.get(
8084
url,
8185
params=params,
82-
auth=qiniu.auth.RequestsAuth(auth) if auth is not None else None,
86+
auth=auth,
8387
timeout=config.get_default('connection_timeout'),
84-
headers=_headers)
88+
headers=post_headers)
8589
except Exception as e:
8690
return None, ResponseInfo(None, e)
8791
return __return_wrapper(r)
@@ -108,10 +112,18 @@ def _post_with_auth(url, data, auth):
108112
return _post(url, data, None, qiniu.auth.RequestsAuth(auth))
109113

110114

115+
def _get_with_auth(url, data, auth):
116+
return _get(url, data, qiniu.auth.RequestsAuth(auth))
117+
118+
111119
def _post_with_auth_and_headers(url, data, auth, headers):
112120
return _post(url, data, None, qiniu.auth.RequestsAuth(auth), headers)
113121

114122

123+
def _get_with_auth_and_headers(url, data, auth, headers):
124+
return _get(url, data, qiniu.auth.RequestsAuth(auth), headers)
125+
126+
115127
def _post_with_qiniu_mac_and_headers(url, data, auth, headers):
116128
return _post(url, data, None, qiniu.auth.QiniuMacRequestsAuth(auth), headers)
117129

qiniu/services/cdn/manager.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def get_domain(self, name):
212212
- ResponseInfo 请求的Response信息
213213
"""
214214
url = '{0}/domain/{1}'.format(self.server, name)
215-
return self.__post(url)
215+
return self.__get(url)
216216

217217
def put_httpsconf(self, name, certid, forceHttps):
218218
"""
@@ -268,6 +268,10 @@ def __put(self, url, data=None):
268268
headers = {'Content-Type': 'application/json'}
269269
return http._put_with_auth_and_headers(url, data, self.auth, headers)
270270

271+
def __get(self, url, data=None):
272+
headers = {'Content-Type': 'application/json'}
273+
return http._get_with_auth_and_headers(url, data, self.auth, headers)
274+
271275

272276
def create_timestamp_anti_leech_url(host, file_name, query_string, encrypt_key, deadline):
273277
"""

qiniu/services/storage/bucket.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ def __post(self, url, data=None):
367367
return http._post_with_auth(url, data, self.auth)
368368

369369
def __get(self, url, params=None):
370-
return http._get(url, params, self.auth)
370+
return http._get_with_auth(url, params, self.auth)
371371

372372

373373
def _build_op(*args):

qiniu/services/storage/uploader.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def put_data(
2828
一个dict变量,类似 {"hash": "<Hash string>", "key": "<Key string>"}
2929
一个ResponseInfo对象
3030
"""
31-
final_data = ''
31+
final_data = b''
3232
if hasattr(data, 'read'):
3333
while True:
3434
tmp_data = data.read(config._BLOCK_SIZE)

test_qiniu.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from qiniu import Auth, set_default, etag, PersistentFop, build_op, op_save, Zone
1313
from qiniu import put_data, put_file, put_stream
1414
from qiniu import BucketManager, build_batch_copy, build_batch_rename, build_batch_move, build_batch_stat, \
15-
build_batch_delete
15+
build_batch_delete,DomainManager
1616
from qiniu import urlsafe_base64_encode, urlsafe_base64_decode
1717

1818
from qiniu.compat import is_py2, is_py3, b
@@ -455,6 +455,15 @@ def test_large_size(self):
455455
remove_temp_file(localfile)
456456

457457

458+
class CdnTestCase(unittest.TestCase):
459+
q = Auth(access_key, secret_key)
460+
domain_manager = DomainManager(q)
461+
462+
ret, info = domain_manager.get_domain('pythonsdk.qiniu.io')
463+
print(info)
464+
assert info.status_code == 200
465+
466+
458467
class ReadWithoutSeek(object):
459468
def __init__(self, str):
460469
self.str = str

0 commit comments

Comments
 (0)