python-fasthtml 0.14.25__tar.gz → 0.14.26__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.
- {python_fasthtml-0.14.25/python_fasthtml.egg-info → python_fasthtml-0.14.26}/PKG-INFO +1 -1
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/fasthtml/__init__.py +1 -1
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/fasthtml/proxy.py +2 -2
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26/python_fasthtml.egg-info}/PKG-INFO +1 -1
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/tests/test_fh.py +4 -1
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/CONTRIBUTING.md +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/LICENSE +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/MANIFEST.in +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/README.md +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/fasthtml/_modidx.py +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/fasthtml/authmw.py +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/fasthtml/basics.py +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/fasthtml/cli.py +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/fasthtml/common.py +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/fasthtml/components.py +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/fasthtml/components.pyi +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/fasthtml/core.py +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/fasthtml/core.pyi +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/fasthtml/fastapp.py +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/fasthtml/ft.py +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/fasthtml/js.py +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/fasthtml/jupyter.py +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/fasthtml/katex.js +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/fasthtml/live_reload.py +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/fasthtml/oauth.py +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/fasthtml/pico.py +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/fasthtml/skill.py +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/fasthtml/starlette.py +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/fasthtml/stripe_otp.py +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/fasthtml/svg.py +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/fasthtml/toaster.py +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/fasthtml/xtend.py +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/fasthtml/xtend.pyi +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/pyproject.toml +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/python_fasthtml.egg-info/SOURCES.txt +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/python_fasthtml.egg-info/dependency_links.txt +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/python_fasthtml.egg-info/entry_points.txt +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/python_fasthtml.egg-info/requires.txt +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/python_fasthtml.egg-info/top_level.txt +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/setup.cfg +0 -0
- {python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/tests/test_proxy.py +0 -0
|
@@ -72,11 +72,11 @@ class ProxyResponse(Response):
|
|
|
72
72
|
async def proxy_websocket(
|
|
73
73
|
websocket, # Incoming Starlette WebSocket, not yet accepted
|
|
74
74
|
url, # Complete upstream WebSocket URL, including query parameters
|
|
75
|
-
headers=None, # Additional upstream
|
|
75
|
+
headers=None, # Additional upstream headers, as a mapping or string/byte pairs
|
|
76
76
|
):
|
|
77
77
|
"Relay text and binary frames until either peer disconnects."
|
|
78
78
|
try:
|
|
79
|
-
async with websockets.connect(url, additional_headers=headers,
|
|
79
|
+
async with websockets.connect(url, additional_headers=httpx2.Headers(headers).multi_items(),
|
|
80
80
|
subprotocols=websocket.scope['subprotocols'] or None, max_size=None) as target:
|
|
81
81
|
await websocket.accept(subprotocol=target.subprotocol)
|
|
82
82
|
async def to_target():
|
|
@@ -71,6 +71,7 @@ async def echo_http(request):
|
|
|
71
71
|
async def echo_ws(ws):
|
|
72
72
|
if status := ws.query_params.get('deny'): return await ws.send_denial_response(Response(status_code=int(status)))
|
|
73
73
|
await ws.accept(subprotocol='echo')
|
|
74
|
+
await ws.send_text(ws.headers.get('x-api-token', ''))
|
|
74
75
|
await ws.send_text(await ws.receive_text())
|
|
75
76
|
await ws.send_bytes(await ws.receive_bytes())
|
|
76
77
|
await ws.close(code=1000)
|
|
@@ -80,7 +81,8 @@ def test_proxy():
|
|
|
80
81
|
with running_server(upstream) as url:
|
|
81
82
|
async def forward_http(request):
|
|
82
83
|
return ProxyResponse(request, url, headers=proxy_headers(request.headers, exclude=(b'authorization',)))
|
|
83
|
-
async def forward_ws(ws):
|
|
84
|
+
async def forward_ws(ws):
|
|
85
|
+
await proxy_websocket(ws, url.replace('http', 'ws')+'/ws?'+ws.url.query, headers=[(b'x-api-token', b'user:key')])
|
|
84
86
|
app = Starlette(routes=[Route('/', forward_http, methods=['PATCH']), WebSocketRoute('/ws', forward_ws)])
|
|
85
87
|
with TestClient(app) as proxy:
|
|
86
88
|
body = b'["a", {"b":2}]'
|
|
@@ -93,6 +95,7 @@ def test_proxy():
|
|
|
93
95
|
assert res.headers.get_list('x-tag') == ['a', 'b']
|
|
94
96
|
with proxy.websocket_connect('/ws', subprotocols=['echo']) as ws:
|
|
95
97
|
assert ws.accepted_subprotocol == 'echo'
|
|
98
|
+
assert ws.receive_text() == 'user:key'
|
|
96
99
|
ws.send_text('hello')
|
|
97
100
|
assert ws.receive_text() == 'hello'
|
|
98
101
|
ws.send_bytes(b'\x00bytes')
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/python_fasthtml.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{python_fasthtml-0.14.25 → python_fasthtml-0.14.26}/python_fasthtml.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|