This commit is contained in:
JJTech0130 2023-08-17 20:06:57 -04:00
parent b5f644b989
commit 42be2de947
No known key found for this signature in database
GPG key ID: 23C92EBCCF8F93D6

View file

@ -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")