wslink 2.0.5__py3-none-any.whl → 2.1.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.
- wslink/backends/aiohttp/__init__.py +16 -10
- {wslink-2.0.5.dist-info → wslink-2.1.1.dist-info}/METADATA +2 -1
- {wslink-2.0.5.dist-info → wslink-2.1.1.dist-info}/RECORD +5 -5
- {wslink-2.0.5.dist-info → wslink-2.1.1.dist-info}/WHEEL +0 -0
- {wslink-2.0.5.dist-info → wslink-2.1.1.dist-info}/top_level.txt +0 -0
@@ -1,11 +1,14 @@
|
|
1
|
-
import
|
1
|
+
from __future__ import annotations
|
2
2
|
import os
|
3
3
|
import logging
|
4
4
|
import sys
|
5
5
|
import uuid
|
6
|
+
import json
|
7
|
+
from pathlib import Path
|
6
8
|
|
7
9
|
from wslink.protocol import WslinkHandler, AbstractWebApp
|
8
10
|
|
11
|
+
|
9
12
|
# Backend specific imports
|
10
13
|
import aiohttp
|
11
14
|
import aiohttp.web as aiohttp_web
|
@@ -15,6 +18,10 @@ import aiohttp.web as aiohttp_web
|
|
15
18
|
MSG_OVERHEAD = int(os.environ.get("WSLINK_MSG_OVERHEAD", 4096))
|
16
19
|
MAX_MSG_SIZE = int(os.environ.get("WSLINK_MAX_MSG_SIZE", 4194304))
|
17
20
|
HEART_BEAT = int(os.environ.get("WSLINK_HEART_BEAT", 30)) # 30 seconds
|
21
|
+
HTTP_HEADERS: str | None = os.environ.get("WSLINK_HTTP_HEADERS") # path to json file
|
22
|
+
|
23
|
+
if HTTP_HEADERS and Path(HTTP_HEADERS).exists():
|
24
|
+
HTTP_HEADERS: dict = json.loads(Path(HTTP_HEADERS).read_text())
|
18
25
|
|
19
26
|
logger = logging.getLogger(__name__)
|
20
27
|
|
@@ -35,17 +42,13 @@ def _fix_path(path):
|
|
35
42
|
return path
|
36
43
|
|
37
44
|
|
38
|
-
# -----------------------------------------------------------------------------
|
39
|
-
# Needed for WASM/sharedArrayBuffer
|
40
|
-
# => we should find a way to dynamically provided needed header
|
41
45
|
# -----------------------------------------------------------------------------
|
42
46
|
@aiohttp_web.middleware
|
43
|
-
async def
|
47
|
+
async def http_headers(request: aiohttp_web.Request, handler):
|
44
48
|
response: aiohttp_web.Response = await handler(request)
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
response.headers.setdefault("Cache-Control", "no-store")
|
49
|
+
for k, v in HTTP_HEADERS.items():
|
50
|
+
response.headers.setdefault(k, v)
|
51
|
+
|
49
52
|
return response
|
50
53
|
|
51
54
|
|
@@ -53,7 +56,10 @@ async def shared_array_buffer_headers(request: aiohttp_web.Request, handler):
|
|
53
56
|
class WebAppServer(AbstractWebApp):
|
54
57
|
def __init__(self, server_config):
|
55
58
|
AbstractWebApp.__init__(self, server_config)
|
56
|
-
|
59
|
+
if HTTP_HEADERS:
|
60
|
+
self.set_app(aiohttp_web.Application(middlewares=[http_headers]))
|
61
|
+
else:
|
62
|
+
self.set_app(aiohttp_web.Application())
|
57
63
|
self._ws_handlers = []
|
58
64
|
self._site = None
|
59
65
|
self._runner = None
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: wslink
|
3
|
-
Version: 2.
|
3
|
+
Version: 2.1.1
|
4
4
|
Summary: Python/JavaScript library for communicating over WebSocket
|
5
5
|
Home-page: https://github.com/kitware/wslink
|
6
6
|
Author: Kitware, Inc.
|
@@ -65,6 +65,7 @@ Those only apply for the Python server and launcher.
|
|
65
65
|
* WSLINK_LAUNCHER_DELETE - If set to 1 this will enable the DELETE endpoint for killing a running session
|
66
66
|
* WSLINK_MAX_MSG_SIZE - Number of bytes for a message size (default: 4194304)
|
67
67
|
* WSLINK_HEART_BEAT - Number of seconds between heartbeats (default: 30)
|
68
|
+
* WSLINK_HTTP_HEADERS - Path to json file containing HTTP headers to be added
|
68
69
|
|
69
70
|
License
|
70
71
|
-------
|
@@ -10,7 +10,7 @@ wslink/ssl_context.py,sha256=hNOJJCdrStws1Qf6vPvY4vTk9Bf8J5d90W3fS0cRv8o,2290
|
|
10
10
|
wslink/uri.py,sha256=woCQ4yChUqTMg9IT6YYDtUYeKmCg7OUCEgeBGA-19DY,384
|
11
11
|
wslink/websocket.py,sha256=pBiWqkL8Zn8LuSJ9nv3yA-KjEynbolOQ2gLHtQFJ2Ic,4611
|
12
12
|
wslink/backends/__init__.py,sha256=cyJGjm-YyBSyOEX81owyTbJ3YnrA6dB7--B4LnsEtHI,1214
|
13
|
-
wslink/backends/aiohttp/__init__.py,sha256=
|
13
|
+
wslink/backends/aiohttp/__init__.py,sha256=Bc3uPVrhNXnn5Xt3Tck2Th-dsysz1VAnQdh8WzRn1y0,9253
|
14
14
|
wslink/backends/aiohttp/launcher.py,sha256=gHNMvtgNHEwBN_QBRDSCrTp2B4K1PsfV81rKaHi7Cxo,8897
|
15
15
|
wslink/backends/aiohttp/relay.py,sha256=oZAzIQTpsQaObWXaa-_VtoTOUQALC_QLDd9UvWspYaU,13311
|
16
16
|
wslink/backends/generic/__init__.py,sha256=Qu65gWsd2xCSsxybnDtEDI5vMjHN-F5jgPZOyNIxnGs,112
|
@@ -19,7 +19,7 @@ wslink/backends/jupyter/__init__.py,sha256=Qu65gWsd2xCSsxybnDtEDI5vMjHN-F5jgPZOy
|
|
19
19
|
wslink/backends/jupyter/core.py,sha256=PCQN-uZPFROnRv8B5dNwnwHV67o4Bpme3_Z6V-zbOUA,3864
|
20
20
|
wslink/backends/tornado/__init__.py,sha256=Qu65gWsd2xCSsxybnDtEDI5vMjHN-F5jgPZOyNIxnGs,112
|
21
21
|
wslink/backends/tornado/core.py,sha256=tPMkkhWuO_ovkisVim0zcegwZKEAG4IRUdd_O_0a_R0,2157
|
22
|
-
wslink-2.
|
23
|
-
wslink-2.
|
24
|
-
wslink-2.
|
25
|
-
wslink-2.
|
22
|
+
wslink-2.1.1.dist-info/METADATA,sha256=oO-nFJoYE5H1GuJGMtRWgzZ4zrpEWgGLRkeaivNzIh8,3123
|
23
|
+
wslink-2.1.1.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
24
|
+
wslink-2.1.1.dist-info/top_level.txt,sha256=N0d8eqvhwhfW1p1yPTmvxlbzhjz7ZyhBfysNvaFqpQY,7
|
25
|
+
wslink-2.1.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|