Skip to content

Conversation

@thrau
Copy link
Member

@thrau thrau commented Jan 30, 2026

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 Header subclass 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 HeaderPreservingHTTPChannel and HeaderPreservingWSGIResponse are 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 to serve_twisted_websocket_listener, the tests would fail.
Anyway, I think it's OK, since no one really instantiates manually a Site object for serving rolo routers, and for serving Gateway instances we already have the documented TwistedGateway(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 by HeaderPreservingHTTPChannel.headerReceived, and HeaderPreservingWSGIResponse.startResponse anyway.

Changes

  • Rolo now supports twisted >=24.10

@thrau thrau requested a review from bentsku as a code owner January 30, 2026 22:20
@thrau
Copy link
Member Author

thrau commented Jan 30, 2026

I've also released localstack-twisted 25.5.0 which can be upgraded together with rolo in localstack

Copy link
Collaborator

@bentsku bentsku left a comment

Choose a reason for hiding this comment

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

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 👍

@bentsku bentsku merged commit ac3aafe into main Feb 1, 2026
4 checks passed
@bentsku bentsku deleted the twisted-upgrade branch February 1, 2026 19:38
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.

3 participants