Skip to content

Commit 4d39f6d

Browse files
committed
👽 using short form of leancloud related headers
1 parent c99439c commit 4d39f6d

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

leancloud/client.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -73,26 +73,25 @@ def new_func(*args, **kwargs):
7373

7474
headers = {
7575
'Content-Type': 'application/json;charset=utf-8',
76-
'X-AVOSCloud-Application-Id': APP_ID,
77-
'X-AVOSCloud-Application-Production': USE_PRODUCTION,
76+
'X-LC-Id': APP_ID,
77+
'X-LC-Prod': USE_PRODUCTION,
7878
'User-Agent': 'AVOS Cloud python-{0} SDK'.format(leancloud.__version__),
7979
}
8080
md5sum = hashlib.md5()
8181
current_time = six.text_type(int(time.time() * 1000))
8282
if (USE_MASTER_KEY is None and MASTER_KEY) or USE_MASTER_KEY is True:
83-
# md5sum.update(current_time + MASTER_KEY)
84-
# headers['X-AVOSCloud-Request-Sign'] = md5sum.hexdigest() + ',' + current_time + ',master'
85-
headers['X-AVOSCloud-Master-Key'] = MASTER_KEY
83+
md5sum.update((current_time + MASTER_KEY).encode('utf-8'))
84+
headers['X-LC-Sign'] = md5sum.hexdigest() + ',' + current_time + ',master'
8685
else:
8786
# In python 2.x, you can feed this object with arbitrary
8887
# strings using the update() method, but in python 3.x,
8988
# you should feed with bytes-like objects.
9089
md5sum.update((current_time + APP_KEY).encode('utf-8'))
91-
headers['X-AVOSCloud-Request-Sign'] = md5sum.hexdigest() + ',' + current_time
90+
headers['X-LC-Sign'] = md5sum.hexdigest() + ',' + current_time
9291

9392
user = leancloud.User.get_current()
9493
if user:
95-
headers['X-AVOSCloud-Session-Token'] = user._session_token
94+
headers['X-LC-Session'] = user._session_token
9695

9796
return func(headers=headers, *args, **kwargs)
9897
return new_func

0 commit comments

Comments
 (0)