python-engineio 4.12.3__py3-none-any.whl → 4.13.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- engineio/async_client.py +11 -8
- engineio/async_drivers/aiohttp.py +9 -16
- engineio/async_drivers/asgi.py +3 -3
- engineio/async_drivers/tornado.py +2 -1
- engineio/async_server.py +8 -6
- engineio/client.py +9 -5
- engineio/server.py +4 -3
- {python_engineio-4.12.3.dist-info → python_engineio-4.13.1.dist-info}/METADATA +6 -3
- {python_engineio-4.12.3.dist-info → python_engineio-4.13.1.dist-info}/RECORD +12 -12
- {python_engineio-4.12.3.dist-info → python_engineio-4.13.1.dist-info}/WHEEL +1 -1
- {python_engineio-4.12.3.dist-info → python_engineio-4.13.1.dist-info}/licenses/LICENSE +0 -0
- {python_engineio-4.12.3.dist-info → python_engineio-4.13.1.dist-info}/top_level.txt +0 -0
engineio/async_client.py
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
+
from http.cookies import SimpleCookie
|
|
3
|
+
import inspect
|
|
2
4
|
import signal
|
|
3
5
|
import ssl
|
|
4
6
|
import threading
|
|
@@ -53,10 +55,11 @@ class AsyncClient(base_client.BaseClient):
|
|
|
53
55
|
use. To disable logging set to ``False``. The default is
|
|
54
56
|
``False``. Note that fatal errors are logged even when
|
|
55
57
|
``logger`` is ``False``.
|
|
56
|
-
:param json: An alternative
|
|
58
|
+
:param json: An alternative JSON module to use for encoding and decoding
|
|
57
59
|
packets. Custom json modules must have ``dumps`` and ``loads``
|
|
58
60
|
functions that are compatible with the standard library
|
|
59
|
-
versions.
|
|
61
|
+
versions. This is a process-wide setting, all instantiated
|
|
62
|
+
servers and clients must use the same JSON module.
|
|
60
63
|
:param request_timeout: A timeout in seconds for requests. The default is
|
|
61
64
|
5 seconds.
|
|
62
65
|
:param http_session: an initialized ``aiohttp.ClientSession`` object to be
|
|
@@ -319,16 +322,16 @@ class AsyncClient(base_client.BaseClient):
|
|
|
319
322
|
|
|
320
323
|
# extract any new cookies passed in a header so that they can also be
|
|
321
324
|
# sent the the WebSocket route
|
|
322
|
-
cookies = {}
|
|
323
325
|
for header, value in headers.items():
|
|
324
326
|
if header.lower() == 'cookie':
|
|
325
|
-
|
|
326
|
-
|
|
327
|
+
ck = SimpleCookie(headers[header])
|
|
328
|
+
self.http.cookie_jar.update_cookies(
|
|
329
|
+
{k: m.value for k, m in ck.items()})
|
|
327
330
|
del headers[header]
|
|
328
331
|
break
|
|
329
|
-
self.http.cookie_jar.update_cookies(cookies)
|
|
330
332
|
|
|
331
|
-
extra_options = {
|
|
333
|
+
extra_options = {
|
|
334
|
+
'timeout': aiohttp.ClientWSTimeout(ws_close=self.request_timeout)}
|
|
332
335
|
if not self.ssl_verify:
|
|
333
336
|
ssl_context = ssl.create_default_context()
|
|
334
337
|
ssl_context.check_hostname = False
|
|
@@ -468,7 +471,7 @@ class AsyncClient(base_client.BaseClient):
|
|
|
468
471
|
run_async = kwargs.pop('run_async', False)
|
|
469
472
|
ret = None
|
|
470
473
|
if event in self.handlers:
|
|
471
|
-
if
|
|
474
|
+
if inspect.iscoroutinefunction(self.handlers[event]) is True:
|
|
472
475
|
if run_async:
|
|
473
476
|
task = self.start_background_task(self.handlers[event],
|
|
474
477
|
*args)
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import inspect
|
|
2
2
|
import sys
|
|
3
|
-
from urllib.parse import urlsplit
|
|
4
3
|
|
|
5
4
|
from aiohttp.web import Response, WebSocketResponse
|
|
6
5
|
|
|
@@ -22,12 +21,8 @@ def translate_request(request):
|
|
|
22
21
|
"""This function takes the arguments passed to the request handler and
|
|
23
22
|
uses them to generate a WSGI compatible environ dictionary.
|
|
24
23
|
"""
|
|
25
|
-
message = request._message
|
|
26
|
-
payload = request._payload
|
|
27
|
-
|
|
28
|
-
uri_parts = urlsplit(message.path)
|
|
29
24
|
environ = {
|
|
30
|
-
'wsgi.input':
|
|
25
|
+
'wsgi.input': request.content,
|
|
31
26
|
'wsgi.errors': sys.stderr,
|
|
32
27
|
'wsgi.version': (1, 0),
|
|
33
28
|
'wsgi.async': True,
|
|
@@ -35,10 +30,10 @@ def translate_request(request):
|
|
|
35
30
|
'wsgi.multiprocess': False,
|
|
36
31
|
'wsgi.run_once': False,
|
|
37
32
|
'SERVER_SOFTWARE': 'aiohttp',
|
|
38
|
-
'REQUEST_METHOD':
|
|
39
|
-
'QUERY_STRING':
|
|
40
|
-
'RAW_URI':
|
|
41
|
-
'SERVER_PROTOCOL': 'HTTP
|
|
33
|
+
'REQUEST_METHOD': request.method,
|
|
34
|
+
'QUERY_STRING': request.query_string or '',
|
|
35
|
+
'RAW_URI': request.path_qs,
|
|
36
|
+
'SERVER_PROTOCOL': f'HTTP/{request.version[0]}.{request.version[1]}',
|
|
42
37
|
'REMOTE_ADDR': '127.0.0.1',
|
|
43
38
|
'REMOTE_PORT': '0',
|
|
44
39
|
'SERVER_NAME': 'aiohttp',
|
|
@@ -46,7 +41,7 @@ def translate_request(request):
|
|
|
46
41
|
'aiohttp.request': request
|
|
47
42
|
}
|
|
48
43
|
|
|
49
|
-
for hdr_name, hdr_value in
|
|
44
|
+
for hdr_name, hdr_value in request.headers.items():
|
|
50
45
|
hdr_name = hdr_name.upper()
|
|
51
46
|
if hdr_name == 'CONTENT-TYPE':
|
|
52
47
|
environ['CONTENT_TYPE'] = hdr_value
|
|
@@ -63,9 +58,7 @@ def translate_request(request):
|
|
|
63
58
|
|
|
64
59
|
environ['wsgi.url_scheme'] = environ.get('HTTP_X_FORWARDED_PROTO', 'http')
|
|
65
60
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
environ['PATH_INFO'] = path_info
|
|
61
|
+
environ['PATH_INFO'] = request.path
|
|
69
62
|
environ['SCRIPT_NAME'] = ''
|
|
70
63
|
|
|
71
64
|
return environ
|
|
@@ -105,7 +98,7 @@ class WebSocket: # pragma: no cover
|
|
|
105
98
|
f = self._sock.send_bytes
|
|
106
99
|
else:
|
|
107
100
|
f = self._sock.send_str
|
|
108
|
-
if
|
|
101
|
+
if inspect.iscoroutinefunction(f):
|
|
109
102
|
await f(message)
|
|
110
103
|
else:
|
|
111
104
|
f(message)
|
engineio/async_drivers/asgi.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import inspect
|
|
1
2
|
import os
|
|
2
3
|
import sys
|
|
3
|
-
import asyncio
|
|
4
4
|
|
|
5
5
|
from engineio.static_files import get_static_file
|
|
6
6
|
|
|
@@ -102,7 +102,7 @@ class ASGIApp:
|
|
|
102
102
|
if self.on_startup:
|
|
103
103
|
try:
|
|
104
104
|
await self.on_startup() \
|
|
105
|
-
if
|
|
105
|
+
if inspect.iscoroutinefunction(self.on_startup) \
|
|
106
106
|
else self.on_startup()
|
|
107
107
|
except:
|
|
108
108
|
await send({'type': 'lifespan.startup.failed'})
|
|
@@ -112,7 +112,7 @@ class ASGIApp:
|
|
|
112
112
|
if self.on_shutdown:
|
|
113
113
|
try:
|
|
114
114
|
await self.on_shutdown() \
|
|
115
|
-
if
|
|
115
|
+
if inspect.iscoroutinefunction(self.on_shutdown) \
|
|
116
116
|
else self.on_shutdown()
|
|
117
117
|
except:
|
|
118
118
|
await send({'type': 'lifespan.shutdown.failed'})
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
+
import inspect
|
|
2
3
|
import sys
|
|
3
4
|
from urllib.parse import urlsplit
|
|
4
5
|
from .. import exceptions
|
|
@@ -24,7 +25,7 @@ def get_tornado_handler(engineio_server):
|
|
|
24
25
|
async def get(self, *args, **kwargs):
|
|
25
26
|
if self.request.headers.get('Upgrade', '').lower() == 'websocket':
|
|
26
27
|
ret = super().get(*args, **kwargs)
|
|
27
|
-
if
|
|
28
|
+
if inspect.iscoroutine(ret):
|
|
28
29
|
await ret
|
|
29
30
|
else:
|
|
30
31
|
await engineio_server.handle_request(self)
|
engineio/async_server.py
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
+
import inspect
|
|
2
3
|
import urllib
|
|
3
4
|
|
|
4
5
|
from . import base_server
|
|
@@ -63,10 +64,11 @@ class AsyncServer(base_server.BaseServer):
|
|
|
63
64
|
:param logger: To enable logging set to ``True`` or pass a logger object to
|
|
64
65
|
use. To disable logging set to ``False``. Note that fatal
|
|
65
66
|
errors are logged even when ``logger`` is ``False``.
|
|
66
|
-
:param json: An alternative
|
|
67
|
-
packets. Custom
|
|
67
|
+
:param json: An alternative JSON module to use for encoding and decoding
|
|
68
|
+
packets. Custom JSON modules must have ``dumps`` and ``loads``
|
|
68
69
|
functions that are compatible with the standard library
|
|
69
|
-
versions.
|
|
70
|
+
versions. This is a process-wide setting, all instantiated
|
|
71
|
+
servers and clients must use the same JSON module.
|
|
70
72
|
:param async_handlers: If set to ``True``, run message event handlers in
|
|
71
73
|
non-blocking threads. To run handlers synchronously,
|
|
72
74
|
set to ``False``. The default is ``True``.
|
|
@@ -212,7 +214,7 @@ class AsyncServer(base_server.BaseServer):
|
|
|
212
214
|
Note: this method is a coroutine.
|
|
213
215
|
"""
|
|
214
216
|
translate_request = self._async['translate_request']
|
|
215
|
-
if
|
|
217
|
+
if inspect.iscoroutinefunction(translate_request):
|
|
216
218
|
environ = await translate_request(*args, **kwargs)
|
|
217
219
|
else:
|
|
218
220
|
environ = translate_request(*args, **kwargs)
|
|
@@ -427,7 +429,7 @@ class AsyncServer(base_server.BaseServer):
|
|
|
427
429
|
async def _make_response(self, response_dict, environ):
|
|
428
430
|
cors_headers = self._cors_headers(environ)
|
|
429
431
|
make_response = self._async['make_response']
|
|
430
|
-
if
|
|
432
|
+
if inspect.iscoroutinefunction(make_response):
|
|
431
433
|
response = await make_response(
|
|
432
434
|
response_dict['status'],
|
|
433
435
|
response_dict['headers'] + cors_headers,
|
|
@@ -502,7 +504,7 @@ class AsyncServer(base_server.BaseServer):
|
|
|
502
504
|
run_async = kwargs.pop('run_async', False)
|
|
503
505
|
ret = None
|
|
504
506
|
if event in self.handlers:
|
|
505
|
-
if
|
|
507
|
+
if inspect.iscoroutinefunction(self.handlers[event]):
|
|
506
508
|
async def run_async_handler():
|
|
507
509
|
try:
|
|
508
510
|
try:
|
engineio/client.py
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
from base64 import b64encode
|
|
2
|
-
from
|
|
2
|
+
from http.cookies import SimpleCookie
|
|
3
3
|
import logging
|
|
4
4
|
import queue
|
|
5
5
|
import ssl
|
|
6
6
|
import threading
|
|
7
7
|
import time
|
|
8
8
|
import urllib
|
|
9
|
+
from engineio.json import JSONDecodeError
|
|
9
10
|
|
|
10
11
|
try:
|
|
11
12
|
import requests
|
|
@@ -33,10 +34,11 @@ class Client(base_client.BaseClient):
|
|
|
33
34
|
use. To disable logging set to ``False``. The default is
|
|
34
35
|
``False``. Note that fatal errors are logged even when
|
|
35
36
|
``logger`` is ``False``.
|
|
36
|
-
:param json: An alternative
|
|
37
|
+
:param json: An alternative JSON module to use for encoding and decoding
|
|
37
38
|
packets. Custom json modules must have ``dumps`` and ``loads``
|
|
38
39
|
functions that are compatible with the standard library
|
|
39
|
-
versions.
|
|
40
|
+
versions. This is a process-wide setting, all instantiated
|
|
41
|
+
servers and clients must use the same JSON module.
|
|
40
42
|
:param request_timeout: A timeout in seconds for requests. The default is
|
|
41
43
|
5 seconds.
|
|
42
44
|
:param http_session: an initialized ``requests.Session`` object to be used
|
|
@@ -268,8 +270,10 @@ class Client(base_client.BaseClient):
|
|
|
268
270
|
extra_options = {}
|
|
269
271
|
if self.http:
|
|
270
272
|
# cookies
|
|
271
|
-
|
|
272
|
-
|
|
273
|
+
ck = SimpleCookie()
|
|
274
|
+
for cookie in self.http.cookies:
|
|
275
|
+
ck[cookie.name] = cookie.value
|
|
276
|
+
cookies = ck.output(header='', sep=';').strip()
|
|
273
277
|
for header, value in headers.items():
|
|
274
278
|
if header.lower() == 'cookie':
|
|
275
279
|
if cookies:
|
engineio/server.py
CHANGED
|
@@ -63,10 +63,11 @@ class Server(base_server.BaseServer):
|
|
|
63
63
|
use. To disable logging set to ``False``. The default is
|
|
64
64
|
``False``. Note that fatal errors are logged even when
|
|
65
65
|
``logger`` is ``False``.
|
|
66
|
-
:param json: An alternative
|
|
67
|
-
packets. Custom
|
|
66
|
+
:param json: An alternative JSON module to use for encoding and decoding
|
|
67
|
+
packets. Custom JSON modules must have ``dumps`` and ``loads``
|
|
68
68
|
functions that are compatible with the standard library
|
|
69
|
-
versions.
|
|
69
|
+
versions. This is a process-wide setting, all instantiated
|
|
70
|
+
servers and clients must use the same JSON module.
|
|
70
71
|
:param async_handlers: If set to ``True``, run message event handlers in
|
|
71
72
|
non-blocking threads. To run handlers synchronously,
|
|
72
73
|
set to ``False``. The default is ``True``.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python-engineio
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.13.1
|
|
4
4
|
Summary: Engine.IO server and client for Python
|
|
5
5
|
Author-email: Miguel Grinberg <miguel.grinberg@gmail.com>
|
|
6
6
|
License: MIT
|
|
@@ -10,7 +10,7 @@ Classifier: Environment :: Web Environment
|
|
|
10
10
|
Classifier: Intended Audience :: Developers
|
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
|
12
12
|
Classifier: Operating System :: OS Independent
|
|
13
|
-
Requires-Python: >=3.
|
|
13
|
+
Requires-Python: >=3.8
|
|
14
14
|
Description-Content-Type: text/markdown
|
|
15
15
|
License-File: LICENSE
|
|
16
16
|
Requires-Dist: simple-websocket>=0.10.0
|
|
@@ -18,9 +18,12 @@ Provides-Extra: client
|
|
|
18
18
|
Requires-Dist: requests>=2.21.0; extra == "client"
|
|
19
19
|
Requires-Dist: websocket-client>=0.54.0; extra == "client"
|
|
20
20
|
Provides-Extra: asyncio-client
|
|
21
|
-
Requires-Dist: aiohttp>=3.
|
|
21
|
+
Requires-Dist: aiohttp>=3.11; extra == "asyncio-client"
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: tox; extra == "dev"
|
|
22
24
|
Provides-Extra: docs
|
|
23
25
|
Requires-Dist: sphinx; extra == "docs"
|
|
26
|
+
Requires-Dist: furo; extra == "docs"
|
|
24
27
|
Dynamic: license-file
|
|
25
28
|
|
|
26
29
|
python-engineio
|
|
@@ -1,31 +1,31 @@
|
|
|
1
1
|
engineio/__init__.py,sha256=0R2PY1EXu3sicP7mkA0_QxEVGRlFlgvsxfhByqREE1A,481
|
|
2
|
-
engineio/async_client.py,sha256=
|
|
3
|
-
engineio/async_server.py,sha256=
|
|
2
|
+
engineio/async_client.py,sha256=EQzirWwJ_gUinklogHvHN1vz5Ux0zUt-RhGkCureJbE,29976
|
|
3
|
+
engineio/async_server.py,sha256=ONjhNee8oSncqBrWDaaihWG7fhoFasluAmdOh8NYnqI,27557
|
|
4
4
|
engineio/async_socket.py,sha256=nHY0DPPk0FtI9djUnQWtzZ3ce2OD184Tu-Dop7JLg9I,10715
|
|
5
5
|
engineio/base_client.py,sha256=oOdq-zR7kg8QpvAGti0zBIiFBQGyEELwVMZNtcoJ2ig,5827
|
|
6
6
|
engineio/base_server.py,sha256=tTCqc65Vzf-0Be1uunt1FuGxPOvcpOUCxnT5V2mZCWo,14763
|
|
7
7
|
engineio/base_socket.py,sha256=sQqbNSfGhMQG3xzwar6IXMal28C7Q5TIAQRGp74Wt2o,399
|
|
8
|
-
engineio/client.py,sha256
|
|
8
|
+
engineio/client.py,sha256=-9f8kLYOw86QXrFx5PoyI56uHZ1cUKbhVYolTEj-2t8,27784
|
|
9
9
|
engineio/exceptions.py,sha256=FyuMb5qhX9CUYP3fEoe1m-faU96ApdQTSbblaaoo8LA,292
|
|
10
10
|
engineio/json.py,sha256=SG5FTojqd1ix6u0dKXJsZVqqdYioZLO4S2GPL7BKl3U,405
|
|
11
11
|
engineio/middleware.py,sha256=5NKBXz-ftuFErUB_V9IDvRHaSOsjhtW-NnuJtquB1nc,3750
|
|
12
12
|
engineio/packet.py,sha256=YO3gmeKUoKyIsUq2e1z7Zifr5PGeS3gnaCeqR7wj5hQ,3198
|
|
13
13
|
engineio/payload.py,sha256=GIWu0Vnay4WNZlDxHqVgP34tKTBXX58OArJ-mO5zD3E,1539
|
|
14
|
-
engineio/server.py,sha256=
|
|
14
|
+
engineio/server.py,sha256=47pqjDob0XBwS_2gKRHn0DwAf4NHXHHVuYceZ6pFkD8,23087
|
|
15
15
|
engineio/socket.py,sha256=Oaw1E7ZDyOCaS7KV151g1u9rqOf1JJHh5gttEU0cSeA,10342
|
|
16
16
|
engineio/static_files.py,sha256=pwez9LQFaSQXMbtI0vLyD6UDiokQ4rNfmRYgVLKOthc,2064
|
|
17
17
|
engineio/async_drivers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
18
18
|
engineio/async_drivers/_websocket_wsgi.py,sha256=LuOEfKhbAw8SplB5PMpYKIUqfCPEadQEpqeiq_leOIA,949
|
|
19
|
-
engineio/async_drivers/aiohttp.py,sha256=
|
|
20
|
-
engineio/async_drivers/asgi.py,sha256=
|
|
19
|
+
engineio/async_drivers/aiohttp.py,sha256=fgio4z82i93vTojINDLSBiYCXNcAHTSqcqyFa4yqyHs,3624
|
|
20
|
+
engineio/async_drivers/asgi.py,sha256=VxkQg3r-vD7W3X4v2QdB_C5bNS55FJYT2SNBRNaHgds,11383
|
|
21
21
|
engineio/async_drivers/eventlet.py,sha256=n1y4OjPdj4J2GIep5N56O29oa5NQgFJVcTBjyO1C-Gs,1735
|
|
22
22
|
engineio/async_drivers/gevent.py,sha256=hnJHeWdDQE2jfoLCP5DnwVPzsQlcTLJUMA5EVf1UL-k,2962
|
|
23
23
|
engineio/async_drivers/gevent_uwsgi.py,sha256=m6ay5dov9FDQl0fbeiKeE-Orh5LiF6zLlYQ64Oa3T5g,5954
|
|
24
24
|
engineio/async_drivers/sanic.py,sha256=GYX8YWR1GbRm-GkMTAQkfkWbY12MOT1IV2DzH0Xx8Ns,4495
|
|
25
25
|
engineio/async_drivers/threading.py,sha256=ywmG59d4H6OHZjKarBN97-9BHEsRxFEz9YN-E9QAu_I,463
|
|
26
|
-
engineio/async_drivers/tornado.py,sha256=
|
|
27
|
-
python_engineio-4.
|
|
28
|
-
python_engineio-4.
|
|
29
|
-
python_engineio-4.
|
|
30
|
-
python_engineio-4.
|
|
31
|
-
python_engineio-4.
|
|
26
|
+
engineio/async_drivers/tornado.py,sha256=v9uuGk8_HS6DjhoEKXfjHpki1FnydN4wi7eyBMsUTJA,5908
|
|
27
|
+
python_engineio-4.13.1.dist-info/licenses/LICENSE,sha256=yel9Pbwfu82094CLKCzWRtuIev9PUxP-a76NTDFAWpw,1082
|
|
28
|
+
python_engineio-4.13.1.dist-info/METADATA,sha256=jWP1NgC-iIVq_nIphGPFUG-vGPVgYuLoxrC6UgAFlmA,2314
|
|
29
|
+
python_engineio-4.13.1.dist-info/WHEEL,sha256=YLJXdYXQ2FQ0Uqn2J-6iEIC-3iOey8lH3xCtvFLkd8Q,91
|
|
30
|
+
python_engineio-4.13.1.dist-info/top_level.txt,sha256=u8PmNisCZLwRYcWrNLe9wutQ2tt4zNi8IH362c-HWuA,9
|
|
31
|
+
python_engineio-4.13.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|