Skip to content

feat: Rack 3.x and Rails 8.1+ support - #325

Merged
chadlwilson merged 10 commits into
jruby:1.3-stablefrom
chadlwilson:rack-3-upgrade
Sep 8, 2026
Merged

feat: Rack 3.x and Rails 8.1+ support#325
chadlwilson merged 10 commits into
jruby:1.3-stablefrom
chadlwilson:rack-3-upgrade

Conversation

@chadlwilson

@chadlwilson chadlwilson commented Aug 30, 2025

Copy link
Copy Markdown
Contributor

Implements spec compatibility with Rack 3.0 through 3.2.

https://github.com/rack/rack/blob/main/UPGRADE-GUIDE.md

https://github.com/rack/rack/blob/main/SPEC.rdoc

  • fully backward compatible with the existing 2.2 support
  • adds support for
    • ensuring lower case header names
    • additional SERVER_PROTOCOL env key
    • stricter multi-value handling
    • changes to query parsing semantics (delegated to underlying Rack parser) for the little-used ServletEnv style
    • Rack 3 spec-complaint #call streams (sanity test in the Sinatra example)

TODO list

  • "Invalid nested query parsing syntax" support needs review and discussion, especially the inconsistencies in the existing impl depending on
  • Need to vendor rack-session also? rackup? Or rely on Rails/frameworks to bring them in?
    • Not necessary to vendor, because not everything uses either of them
    • actually not sure we should vendor at all these days since everyone is using bundler, right?
  • Check whether removing the HeaderHash wrapper for error app has any effect on Rack 2.2
  • Remove rewindable support on 3.x since it is no longer a requirement?
    • Won't do this now at least, as things still rely on it, seemingly. (e.g the demo apps)
  • Check response header array logic is compatible
    • added much more complete specs
  • Investigate whether we supporting response hijacking at all before
    • nope, force disabled so not relevant
  • Is #call support needed?
    • implemented
  • Are the changes to remove optional environment keys worth it, or easier to just keep them?
    • Fine to remove them I think.
  • Sanity check with examples and warbler
    • Examples updated to Rack 3.2 and JRuby 10 - all seem fine.

@chadlwilson chadlwilson added this to the 1.3.0 milestone Aug 30, 2025

@kares kares left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nice attempt to support both versions, seems maintainable...

Comment thread src/spec/ruby/jruby/rack/integration_spec.rb Outdated
Comment thread src/main/ruby/rack/handler/servlet/servlet_env.rb Outdated
Comment thread src/main/ruby/rack/handler/servlet/servlet_env.rb Outdated
@chadlwilson chadlwilson linked an issue Sep 3, 2025 that may be closed by this pull request
@chadlwilson
chadlwilson force-pushed the rack-3-upgrade branch 2 times, most recently from 52944a0 to c4cd00e Compare September 6, 2025 10:42
@chadlwilson
chadlwilson force-pushed the rack-3-upgrade branch 2 times, most recently from 6279ba8 to c5a7a6e Compare September 25, 2025 18:03
@chadlwilson
chadlwilson force-pushed the rack-3-upgrade branch 3 times, most recently from 0b70f23 to 196095b Compare October 11, 2025 06:01
@chadlwilson chadlwilson self-assigned this Oct 22, 2025
@chadlwilson
chadlwilson force-pushed the rack-3-upgrade branch 2 times, most recently from 5f1d489 to b63259a Compare October 27, 2025 17:32
Comment thread examples/rails8/Gemfile.lock Outdated
@chadlwilson
chadlwilson force-pushed the rack-3-upgrade branch 2 times, most recently from df4109d to 476247d Compare March 5, 2026 04:21
@chadlwilson chadlwilson changed the title (experimental WIP) Rack 3.x support [feat] WIP Rack 3.x support Mar 13, 2026
@chadlwilson chadlwilson changed the title [feat] WIP Rack 3.x support [feat] Rack 3.x and Rails 8.1+ support Mar 16, 2026
@chadlwilson
chadlwilson force-pushed the rack-3-upgrade branch 3 times, most recently from 309c7e7 to 82c16bf Compare April 21, 2026 16:42
@chadlwilson
chadlwilson force-pushed the rack-3-upgrade branch 4 times, most recently from b06caed to 3f56596 Compare September 8, 2026 15:09
chadlwilson and others added 7 commits September 8, 2026 23:49
Rack 3.x allows any header value to be an Array of Strings. The
Content-Type/Content-Length/Transfer-Encoding special cases coerced the
value directly (asJavaString/to_i) and raised on Arrays - now a single
value Array is unwrapped, and multi value Arrays take the generic
addHeader-per-element path instead of erroring.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
DefaultEnv used HttpServletRequest#getHeader which only returns the
first value of a repeated header, dropping e.g. X-Forwarded-For hops.
All values are now joined with ', ' (and Cookie headers re-combined
with '; ' per RFC 6265 / RFC 7540), falling back to getHeader for
containers restricting getHeaders access.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The newline-splitting header write path called chomp! on each yielded
value - a frozen String ending in a newline raised FrozenError, and
non-frozen app-owned header values were being modified in place.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…upport

Replace the earlier non-compliant "unofficial extension" implementation with proper support.
@chadlwilson
chadlwilson marked this pull request as ready for review September 8, 2026 15:52
@chadlwilson
chadlwilson merged commit 8dc49a9 into jruby:1.3-stable Sep 8, 2026
40 checks passed
@chadlwilson
chadlwilson deleted the rack-3-upgrade branch September 8, 2026 15:54
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.

Rack 3.x / Rails 8.1 support

2 participants