Skip to content

Commit d9a9f62

Browse files
GujiasshPangjiping
authored andcommitted
fix(server): honor Connection hop-by-hop headers
1 parent 6dc95bc commit d9a9f62

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

server/src/api/lifecycle.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,12 +446,20 @@ async def proxy_sandbox_endpoint_request(request: Request, sandbox_id: str, port
446446
raise HTTPException(status_code=400, detail="Websocket upgrade is not supported yet")
447447

448448
# Filter headers
449+
hop_by_hop = set(HOP_BY_HOP_HEADERS)
450+
connection_header = request.headers.get("connection")
451+
if connection_header:
452+
hop_by_hop.update(
453+
header.strip().lower()
454+
for header in connection_header.split(",")
455+
if header.strip()
456+
)
449457
headers = {}
450458
for key, value in request.headers.items():
451459
key_lower = key.lower()
452460
if (
453461
key_lower != "host"
454-
and key_lower not in HOP_BY_HOP_HEADERS
462+
and key_lower not in hop_by_hop
455463
and key_lower not in SENSITIVE_HEADERS
456464
):
457465
headers[key] = value

0 commit comments

Comments
 (0)