fix header case handling and support twisted >=24.10#34
Merged
Conversation
Member
Author
|
I've also released localstack-twisted 25.5.0 which can be upgraded together with rolo in localstack |
bentsku
approved these changes
Feb 1, 2026
Collaborator
bentsku
left a comment
There was a problem hiding this comment.
Nice, LGTM! Thanks for tackling this, this is a neat fix and is more understandable 👍 thanks for also making it backward compatible. Looks awesome!
I'll create a new 0.8.0 release with all of this 👍
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
In twisted/twisted#12264, the internal API for header case handling was significantly refactored. Rolo was modifying twisted internals to implement a raw header casing mode, which then broke.
This PR creates a backwards compatible change, that will work with twisted
>24(both pre- and post- refactor versions).Discussion
The PR introduces a new
Headersubclass that implements its own case handling. The main motivation for twisted/twisted#12264 was performance of header encoding, an issue we don't have since we don't actually do any encoding of headers in raw header mode.The drawback of this new class is that
HeaderPreservingHTTPChannelandHeaderPreservingWSGIResponseare no longer compatible with the default twisted request object. This actually surfaced because the way the requestFactory was passed was also changed, and until I added it explicitly toserve_twisted_websocket_listener, the tests would fail.Anyway, I think it's OK, since no one really instantiates manually a
Siteobject for serving rolo routers, and for serving Gateway instances we already have the documentedTwistedGateway(Site)which configures the Site object correctly.I also removed the copying of the default
_caseMappings, since it wasn't doing anything. Their values were always overwritten byHeaderPreservingHTTPChannel.headerReceived, andHeaderPreservingWSGIResponse.startResponseanyway.Changes