Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Dec 3, 2024

Conversation

JiayuXu0
Copy link
Contributor

@JiayuXu0 JiayuXu0 commented Dec 3, 2024

Add compatibility check for request_headers format in websocket handling. New version of websockets has a 'headers' attribute in request_headers, while old version uses request_headers directly.
This change ensures the server can properly handle requests from different versions of the websockets library.

In older versions of python 3.8 websockets, Headers class was located at websockets.datastructures.Headers
In newer versions of python 3.10 websockets, Headers class was moved to websockets.http11.Request

@@ -641,7 +641,11 @@ async def process_request(
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 (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also fix streaming_server.py?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has been also fixed now.

@csukuangfj
Copy link
Collaborator

Thank you for your contribution!

@csukuangfj csukuangfj merged commit 0d6bf52 into k2-fsa:master Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants