Skip to content

Commit

Permalink
support for aiohttp 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelgrinberg committed Mar 5, 2018
1 parent 37b81ae commit 810e759
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 7 additions & 2 deletions engineio/async_aiohttp.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import asyncio
import sys
from urllib.parse import urlsplit

Expand Down Expand Up @@ -100,9 +101,13 @@ async def close(self):

async def send(self, message):
if isinstance(message, bytes):
self._sock.send_bytes(message)
f = self._sock.send_bytes
else:
self._sock.send_str(message)
f = self._sock.send_str
if asyncio.iscoroutinefunction(f):
await f(message)
else:
f(message)

async def wait(self):
msg = await self._sock.receive()
Expand Down
2 changes: 1 addition & 1 deletion engineio/asyncio_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ async def handle_request(self, *args, **kwargs):
self.logger.warning('Method %s not supported', method)
r = self._method_not_found()
if not isinstance(r, dict):
return r or []
return r if r is not None else []
if self.http_compression and \
len(r['response']) >= self.compression_threshold:
encodings = [e.split(';')[0].strip() for e in
Expand Down

0 comments on commit 810e759

Please sign in to comment.