mirror of
https://github.com/Sneed-Group/pypush-plus-plus
synced 2025-01-09 17:33:47 +00:00
bug fix
This commit is contained in:
parent
b5f644b989
commit
42be2de947
1 changed files with 2 additions and 5 deletions
7
apns.py
7
apns.py
|
@ -215,7 +215,7 @@ class APNSConnection:
|
|||
],
|
||||
)
|
||||
|
||||
if token is not None:
|
||||
if token != b"":
|
||||
payload.fields.insert(0, APNSField(0x1, token))
|
||||
|
||||
await self._send(payload)
|
||||
|
@ -338,13 +338,10 @@ class APNSPayload:
|
|||
async def read_from_stream(stream: trio.abc.Stream) -> APNSPayload:
|
||||
"""Reads a payload from the given stream"""
|
||||
id = await stream.receive_some(1)
|
||||
if id is None:
|
||||
if id is None or id == b"":
|
||||
raise Exception("Unable to read payload id from stream")
|
||||
id = int.from_bytes(id, "big")
|
||||
|
||||
if id == 0x0:
|
||||
raise Exception("Received id 0x0, which is not valid")
|
||||
|
||||
length = await stream.receive_some(4)
|
||||
if length is None:
|
||||
raise Exception("Unable to read payload length from stream")
|
||||
|
|
Loading…
Reference in a new issue