Merged
Conversation
07a7d74 to
2928dd3
Compare
alexrashed
reviewed
Feb 10, 2025
Member
alexrashed
left a comment
There was a problem hiding this comment.
Awesome! Thanks for jumping on this and fixing the header casing in the Websocket implementation! I added some PR comments with some questions I have, once we discussed those we should be good to go! 🚀 🦸🏽
alexrashed
approved these changes
Feb 10, 2025
Member
alexrashed
left a comment
There was a problem hiding this comment.
Thanks for the detailed explanations on the questions! The changes are looking great! Kudos for proactively jumping on fixing the issue here in rolo! 🦸🏽 💯
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
While implementing a service that uses WebSockets, I realized we were not keeping header casing with WebSockets served over Twisted, but we would in ASGI.
This was due to a workaround with the saved
rolo.headersthat is not executed in this code path while creating theWebSocketRequest.I've ported the fix over there, and it's exactly the same code that is living in
wsgi.py. However, there isn't really a place for those kind of... utils? So for now it is duplicated.While testing the fix, I realized it was actually fixing the issue in my code served over LocalStack, but was still failing in the unit tests.
This is because the test was served over a simple
Site, when you are supposed to serve it over aWsgiGateway, which contains some logic to preserve header casing. In order to not complicate the unit tests by requiring everything to be a rolo Gateway, I've applied the fix for the WebSocketsSitefixture by adding thesite.protocol = HeaderPreservingHTTPChannel.protocol_factorylike we would in thetwisted.WsgiGateway.Changes
serve_twisted_websocket_listenerto be closer to how Twisted should actually be used (with the Gateway)Request