fix: support both old and new websockets request headers format (#1588)

Co-authored-by: xujiayu <xujiayu@kaihong.com>
This commit is contained in:
JiayuXu
2024-12-03 17:22:12 +08:00
committed by GitHub
parent dc3287f3a8
commit 0d6bf52844
2 changed files with 10 additions and 2 deletions

View File

@@ -584,7 +584,11 @@ class StreamingServer(object):
path: str,
request_headers: websockets.Headers,
) -> Optional[Tuple[http.HTTPStatus, websockets.Headers, bytes]]:
if "sec-websocket-key" not in request_headers:
if "sec-websocket-key" not in (
request_headers.headers # For new request_headers
if hasattr(request_headers, "headers")
else request_headers # For old request_headers
):
# This is a normal HTTP request
if path == "/":
path = "/index.html"