Skip to content

Commit

Permalink
rtmp
Browse files Browse the repository at this point in the history
  • Loading branch information
baiyubin2020 committed Aug 9, 2016
1 parent 9b9e3b4 commit 30a9f12
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
15 changes: 10 additions & 5 deletions oss2/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,21 @@ def _sign_rtmp_url(self, url, bucket_name, channel_name, playlist_name, expires,
expiration_time = int(time.time()) + expires

canonicalized_resource = "/%s/%s" % (bucket_name, channel_name)
canonicalized_params = ''
canonicalized_params = []

if params:
items = params.items()
items.sort()
for k,v in items:
if k != "OSSAccessKeyId" and k != "Signature" and k!= "Expires" and k!= "SecurityToken":
canonicalized_params += '%s:%s\n' % (k, v)

canonicalized_params.append((k, v))

canonicalized_params.sort(key=lambda e: e[0])
canon_params_str = ''
for k, v in canonicalized_params:
canon_params_str += '%s:%s\n' % (k, v)

p = params if params else {}
string_to_sign = str(expiration_time) + "\n" + canonicalized_params + canonicalized_resource
string_to_sign = str(expiration_time) + "\n" + canon_params_str + canonicalized_resource
logging.debug('string_to_sign={0}'.format(string_to_sign))

h = hmac.new(to_bytes(self.secret), to_bytes(string_to_sign), hashlib.sha1)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_live_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def test_list_live_channel(self):
prefix1 = random_string(5)
channel_target = oss2.models.LiveChannelInfoTarget(playlist_name = 'test.m3u8')
channel_info = oss2.models.LiveChannelInfo(target = channel_target)
for index in xrange(0, 200):
for index in range(200):
channel_name_list.append(prefix1 + self._get_fixed_number(10, index))
bucket.create_live_channel(channel_name_list[index], channel_info)

Expand Down
5 changes: 3 additions & 2 deletions tests/test_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,9 @@ def progress_callback(bytes_consumed, total_bytes):

content_got = b''
result = self.bucket.get_object(key, headers={'Accept-Encoding': 'gzip'}, progress_callback=progress_callback)
for chunk in result:
content_got += chunk
content_got = result.read()
#for chunk in result:
# content_got += chunk

self.assertEqual(len(content), len(content_got))
self.assertEqual(content, content_got)
Expand Down

0 comments on commit 30a9f12

Please sign in to comment.