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

Revert handle_fanout_ws behavior to correctly echo the request body #20

Merged
merged 1 commit into from
Dec 11, 2024

Conversation

harmony7
Copy link
Member

In #1, some of the test endpoints were refactored to make them easier to understand.
At that time, it seems that the handle_fanout_ws() function's behavior was changed in a way that lost some of its original echo behavior. This PR reverts that behavior and adds a few comments.

@harmony7
Copy link
Member Author

harmony7 commented Dec 12, 2024

The main difference in this fix is that we are first starting by cloning the incoming request's body directly into the response's body. This is the correct behavior, because the request body may contain more than one encoded WebSocket message in a batch, and to be an echo server all of these messages need to be echoed directly back to the response.

Additionally, OPEN is guaranteed to be the first one in a batch, so checking the first few bytes for it works. If it is found, then the handler adds the subscribe message and WebSocket extension header to the response.

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