wslink 2.0.5__tar.gz → 2.1.0__tar.gz

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.
Files changed (31) hide show
  1. {wslink-2.0.5 → wslink-2.1.0}/PKG-INFO +2 -1
  2. {wslink-2.0.5 → wslink-2.1.0}/README.rst +1 -0
  3. {wslink-2.0.5 → wslink-2.1.0}/setup.cfg +1 -1
  4. {wslink-2.0.5 → wslink-2.1.0}/src/wslink/backends/aiohttp/__init__.py +14 -10
  5. {wslink-2.0.5 → wslink-2.1.0}/src/wslink.egg-info/PKG-INFO +2 -1
  6. {wslink-2.0.5 → wslink-2.1.0}/MANIFEST.in +0 -0
  7. {wslink-2.0.5 → wslink-2.1.0}/setup.py +0 -0
  8. {wslink-2.0.5 → wslink-2.1.0}/src/wslink/LICENSE +0 -0
  9. {wslink-2.0.5 → wslink-2.1.0}/src/wslink/__init__.py +0 -0
  10. {wslink-2.0.5 → wslink-2.1.0}/src/wslink/backends/__init__.py +0 -0
  11. {wslink-2.0.5 → wslink-2.1.0}/src/wslink/backends/aiohttp/launcher.py +0 -0
  12. {wslink-2.0.5 → wslink-2.1.0}/src/wslink/backends/aiohttp/relay.py +0 -0
  13. {wslink-2.0.5 → wslink-2.1.0}/src/wslink/backends/generic/__init__.py +0 -0
  14. {wslink-2.0.5 → wslink-2.1.0}/src/wslink/backends/generic/core.py +0 -0
  15. {wslink-2.0.5 → wslink-2.1.0}/src/wslink/backends/jupyter/__init__.py +0 -0
  16. {wslink-2.0.5 → wslink-2.1.0}/src/wslink/backends/jupyter/core.py +0 -0
  17. {wslink-2.0.5 → wslink-2.1.0}/src/wslink/backends/tornado/__init__.py +0 -0
  18. {wslink-2.0.5 → wslink-2.1.0}/src/wslink/backends/tornado/core.py +0 -0
  19. {wslink-2.0.5 → wslink-2.1.0}/src/wslink/chunking.py +0 -0
  20. {wslink-2.0.5 → wslink-2.1.0}/src/wslink/launcher.py +0 -0
  21. {wslink-2.0.5 → wslink-2.1.0}/src/wslink/protocol.py +0 -0
  22. {wslink-2.0.5 → wslink-2.1.0}/src/wslink/publish.py +0 -0
  23. {wslink-2.0.5 → wslink-2.1.0}/src/wslink/relay.py +0 -0
  24. {wslink-2.0.5 → wslink-2.1.0}/src/wslink/server.py +0 -0
  25. {wslink-2.0.5 → wslink-2.1.0}/src/wslink/ssl_context.py +0 -0
  26. {wslink-2.0.5 → wslink-2.1.0}/src/wslink/uri.py +0 -0
  27. {wslink-2.0.5 → wslink-2.1.0}/src/wslink/websocket.py +0 -0
  28. {wslink-2.0.5 → wslink-2.1.0}/src/wslink.egg-info/SOURCES.txt +0 -0
  29. {wslink-2.0.5 → wslink-2.1.0}/src/wslink.egg-info/dependency_links.txt +0 -0
  30. {wslink-2.0.5 → wslink-2.1.0}/src/wslink.egg-info/requires.txt +0 -0
  31. {wslink-2.0.5 → wslink-2.1.0}/src/wslink.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wslink
3
- Version: 2.0.5
3
+ Version: 2.1.0
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
  -------
@@ -37,6 +37,7 @@ Those only apply for the Python server and launcher.
37
37
  * WSLINK_LAUNCHER_DELETE - If set to 1 this will enable the DELETE endpoint for killing a running session
38
38
  * WSLINK_MAX_MSG_SIZE - Number of bytes for a message size (default: 4194304)
39
39
  * WSLINK_HEART_BEAT - Number of seconds between heartbeats (default: 30)
40
+ * WSLINK_HTTP_HEADERS - Path to json file containing HTTP headers to be added
40
41
 
41
42
  License
42
43
  -------
@@ -1,5 +1,5 @@
1
1
  [metadata]
2
- version = 2.0.5
2
+ version = 2.1.0
3
3
 
4
4
  [egg_info]
5
5
  tag_build =
@@ -1,8 +1,9 @@
1
- import asyncio
2
1
  import os
3
2
  import logging
4
3
  import sys
5
4
  import uuid
5
+ import json
6
+ from pathlib import Path
6
7
 
7
8
  from wslink.protocol import WslinkHandler, AbstractWebApp
8
9
 
@@ -15,6 +16,10 @@ import aiohttp.web as aiohttp_web
15
16
  MSG_OVERHEAD = int(os.environ.get("WSLINK_MSG_OVERHEAD", 4096))
16
17
  MAX_MSG_SIZE = int(os.environ.get("WSLINK_MAX_MSG_SIZE", 4194304))
17
18
  HEART_BEAT = int(os.environ.get("WSLINK_HEART_BEAT", 30)) # 30 seconds
19
+ HTTP_HEADERS: str | None = os.environ.get("WSLINK_HTTP_HEADERS") # path to json file
20
+
21
+ if HTTP_HEADERS and Path(HTTP_HEADERS).exists():
22
+ HTTP_HEADERS: dict = json.loads(Path(HTTP_HEADERS).read_text())
18
23
 
19
24
  logger = logging.getLogger(__name__)
20
25
 
@@ -35,17 +40,13 @@ def _fix_path(path):
35
40
  return path
36
41
 
37
42
 
38
- # -----------------------------------------------------------------------------
39
- # Needed for WASM/sharedArrayBuffer
40
- # => we should find a way to dynamically provided needed header
41
43
  # -----------------------------------------------------------------------------
42
44
  @aiohttp_web.middleware
43
- async def shared_array_buffer_headers(request: aiohttp_web.Request, handler):
45
+ async def http_headers(request: aiohttp_web.Request, handler):
44
46
  response: aiohttp_web.Response = await handler(request)
45
- response.headers.setdefault("Cross-Origin-Opener-Policy", "same-origin")
46
- response.headers.setdefault("Cross-Origin-Embedder-Policy", "require-corp")
47
- response.headers.setdefault("Access-Control-Allow-Origin", "*")
48
- response.headers.setdefault("Cache-Control", "no-store")
47
+ for k, v in HTTP_HEADERS.items():
48
+ response.headers.setdefault(k, v)
49
+
49
50
  return response
50
51
 
51
52
 
@@ -53,7 +54,10 @@ async def shared_array_buffer_headers(request: aiohttp_web.Request, handler):
53
54
  class WebAppServer(AbstractWebApp):
54
55
  def __init__(self, server_config):
55
56
  AbstractWebApp.__init__(self, server_config)
56
- self.set_app(aiohttp_web.Application(middlewares=[shared_array_buffer_headers]))
57
+ if HTTP_HEADERS:
58
+ self.set_app(aiohttp_web.Application(middlewares=[http_headers]))
59
+ else:
60
+ self.set_app(aiohttp_web.Application())
57
61
  self._ws_handlers = []
58
62
  self._site = None
59
63
  self._runner = None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: wslink
3
- Version: 2.0.5
3
+ Version: 2.1.0
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
  -------
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes