aboutsummaryrefslogtreecommitdiff
path: root/discord/http.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2020-04-09 02:46:26 -0400
committerRapptz <[email protected]>2020-07-25 09:59:38 -0400
commit058a1e608b29e56aa06c97ac9feb2f9915a6124d (patch)
tree62c7e42b7fbabcc85f8784dbef2b387dd6ddb8f3 /discord/http.py
parentUse a proper type for the event queue (diff)
downloaddiscord.py-058a1e608b29e56aa06c97ac9feb2f9915a6124d.tar.xz
discord.py-058a1e608b29e56aa06c97ac9feb2f9915a6124d.zip
Fix voice websocket connections
Diffstat (limited to 'discord/http.py')
-rw-r--r--discord/http.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/discord/http.py b/discord/http.py
index a9da4267..00e66ac2 100644
--- a/discord/http.py
+++ b/discord/http.py
@@ -85,6 +85,10 @@ class MaybeUnlock:
if self._unlock:
self.lock.release()
+# For some reason, the Discord voice websocket expects this header to be
+# completely lowercase while aiohttp respects spec and does it as case-insensitive
+aiohttp.hdrs.WEBSOCKET = 'websocket'
+
class HTTPClient:
"""Represents an HTTP client sending HTTP requests to the Discord API."""
@@ -111,13 +115,17 @@ class HTTPClient:
if self.__session.closed:
self.__session = aiohttp.ClientSession(connector=self.connector)
- async def ws_connect(self, url):
+ async def ws_connect(self, url, *, compress=0):
kwargs = {
'proxy_auth': self.proxy_auth,
'proxy': self.proxy,
'max_msg_size': 0,
'timeout': 30.0,
'autoclose': False,
+ 'headers': {
+ 'User-Agent': self.user_agent,
+ },
+ 'compress': compress
}
return await self.__session.ws_connect(url, **kwargs)