Spaces:
Sleeping
Sleeping
Commit ·
4ab4eac
1
Parent(s): a05c7e2
fix: strip accept-encoding + install brotli to prevent 502 on multi-port proxy
Browse files- proxy.py +5 -1
- requirements.txt +1 -0
proxy.py
CHANGED
|
@@ -562,8 +562,12 @@ async def http_proxy(request, port, upstream_base, path, keep_prefix=False):
|
|
| 562 |
return web.Response(status=status, headers=headers, body=body)
|
| 563 |
|
| 564 |
# Forward headers
|
|
|
|
|
|
|
|
|
|
|
|
|
| 565 |
skip = {"host", "connection", "keep-alive", "transfer-encoding",
|
| 566 |
-
"upgrade", "cookie", "content-length"}
|
| 567 |
headers = {k: v for k, v in request.headers.items() if k.lower() not in skip}
|
| 568 |
|
| 569 |
body = await request.read()
|
|
|
|
| 562 |
return web.Response(status=status, headers=headers, body=body)
|
| 563 |
|
| 564 |
# Forward headers
|
| 565 |
+
# Strip `accept-encoding` so the upstream sends an uncompressed body
|
| 566 |
+
# — otherwise apps that reply with brotli (`br`) crash aiohttp.read()
|
| 567 |
+
# (no brotli decoder installed) and the body is unreadable. localhost
|
| 568 |
+
# bandwidth is free, so we always request identity encoding.
|
| 569 |
skip = {"host", "connection", "keep-alive", "transfer-encoding",
|
| 570 |
+
"upgrade", "cookie", "content-length", "accept-encoding"}
|
| 571 |
headers = {k: v for k, v in request.headers.items() if k.lower() not in skip}
|
| 572 |
|
| 573 |
body = await request.read()
|
requirements.txt
CHANGED
|
@@ -2,3 +2,4 @@ jupyterlab==4.5.7
|
|
| 2 |
tornado==6.5.5
|
| 3 |
ipywidgets==8.1.8
|
| 4 |
aiohttp==3.11.16
|
|
|
|
|
|
| 2 |
tornado==6.5.5
|
| 3 |
ipywidgets==8.1.8
|
| 4 |
aiohttp==3.11.16
|
| 5 |
+
brotli==1.1.0
|