Browse Source
Ignore catch-all namespace in client connections (Fixes #1351)
pull/1353/head
Miguel Grinberg
10 months ago
Failed to extract signature
4 changed files with
6 additions and
0 deletions
-
src/socketio/async_client.py
-
src/socketio/client.py
-
tests/async/test_client.py
-
tests/common/test_client.py
|
|
@ -128,6 +128,8 @@ class AsyncClient(base_client.BaseClient): |
|
|
|
if namespaces is None: |
|
|
|
namespaces = list(set(self.handlers.keys()).union( |
|
|
|
set(self.namespace_handlers.keys()))) |
|
|
|
if '*' in namespaces: |
|
|
|
namespaces.remove('*') |
|
|
|
if len(namespaces) == 0: |
|
|
|
namespaces = ['/'] |
|
|
|
elif isinstance(namespaces, str): |
|
|
|
|
|
@ -126,6 +126,8 @@ class Client(base_client.BaseClient): |
|
|
|
if namespaces is None: |
|
|
|
namespaces = list(set(self.handlers.keys()).union( |
|
|
|
set(self.namespace_handlers.keys()))) |
|
|
|
if '*' in namespaces: |
|
|
|
namespaces.remove('*') |
|
|
|
if len(namespaces) == 0: |
|
|
|
namespaces = ['/'] |
|
|
|
elif isinstance(namespaces, str): |
|
|
|
|
|
@ -98,6 +98,7 @@ class TestAsyncClient(unittest.TestCase): |
|
|
|
c.eio.connect = AsyncMock() |
|
|
|
c.on('foo', mock.MagicMock(), namespace='/foo') |
|
|
|
c.on('bar', mock.MagicMock(), namespace='/') |
|
|
|
c.on('baz', mock.MagicMock(), namespace='*') |
|
|
|
_run( |
|
|
|
c.connect( |
|
|
|
'url', |
|
|
|
|
|
@ -236,6 +236,7 @@ class TestClient(unittest.TestCase): |
|
|
|
c.eio.connect = mock.MagicMock() |
|
|
|
c.on('foo', mock.MagicMock(), namespace='/foo') |
|
|
|
c.on('bar', mock.MagicMock(), namespace='/') |
|
|
|
c.on('baz', mock.MagicMock(), namespace='*') |
|
|
|
c.connect( |
|
|
|
'url', |
|
|
|
headers='headers', |
|
|
|