aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRapptz <[email protected]>2017-10-14 15:22:39 -0400
committerRapptz <[email protected]>2017-10-14 15:22:39 -0400
commit92a37c2e4fe77c12ba2b74c6d283ae4b776917c0 (patch)
tree4084d35158b1c225c0fb1f4840d9afff681f46b9
parentImplement zlib streaming for the gateway. (diff)
downloaddiscord.py-92a37c2e4fe77c12ba2b74c6d283ae4b776917c0.tar.xz
discord.py-92a37c2e4fe77c12ba2b74c6d283ae4b776917c0.zip
Revert "Implement zlib streaming for the gateway."
This reverts commit 462191a08b5b2efb83f5bc32935dc546d35a744b.
-rw-r--r--discord/gateway.py16
-rw-r--r--discord/http.py16
2 files changed, 6 insertions, 26 deletions
diff --git a/discord/gateway.py b/discord/gateway.py
index eceb7a28..0ab02760 100644
--- a/discord/gateway.py
+++ b/discord/gateway.py
@@ -186,8 +186,6 @@ class DiscordWebSocket(websockets.client.WebSocketClientProtocol):
# ws related stuff
self.session_id = None
self.sequence = None
- self._zlib = zlib.decompressobj()
- self._buffer = bytearray()
@classmethod
@asyncio.coroutine
@@ -314,18 +312,8 @@ class DiscordWebSocket(websockets.client.WebSocketClientProtocol):
self._dispatch('socket_raw_receive', msg)
if isinstance(msg, bytes):
- self._buffer.extend(msg)
-
- if len(msg) >= 4:
- suffix = int.from_bytes(msg[-4:], byteorder='big')
- if suffix == 0xFFFF:
- msg = self._zlib.decompress(self._buffer)
- msg = msg.decode('utf-8')
- self._buffer = bytearray()
- else:
- return
- else:
- return
+ msg = zlib.decompress(msg, 15, 10490000) # This is 10 MiB
+ msg = msg.decode('utf-8')
msg = json.loads(msg)
diff --git a/discord/http.py b/discord/http.py
index 8c4ebb16..fa6678ee 100644
--- a/discord/http.py
+++ b/discord/http.py
@@ -739,29 +739,21 @@ class HTTPClient:
return self.request(Route('GET', '/oauth2/applications/@me'))
@asyncio.coroutine
- def get_gateway(self, *, encoding='json', v=6, zlib=True):
+ def get_gateway(self):
try:
data = yield from self.request(Route('GET', '/gateway'))
except HTTPException as e:
raise GatewayNotFound() from e
- if zlib:
- value = '{0}?encoding={1}&v={2}&compress=zlib-stream'
- else:
- value = '{0}?encoding={1}&v={2}'
- return value.format(data['url'], encoding, v)
+ return data.get('url') + '?encoding=json&v=6'
@asyncio.coroutine
- def get_bot_gateway(self, *, encoding='json', v=6, zlib=True):
+ def get_bot_gateway(self):
try:
data = yield from self.request(Route('GET', '/gateway/bot'))
except HTTPException as e:
raise GatewayNotFound() from e
-
- if zlib:
- value = '{0}?encoding={1}&v={2}&compress=zlib-stream'
else:
- value = '{0}?encoding={1}&v={2}'
- return data['shards'], value.format(data['url'], encoding, v)
+ return data['shards'], data['url'] + '?encoding=json&v=6'
def get_user_info(self, user_id):
return self.request(Route('GET', '/users/{user_id}', user_id=user_id))