Merged
Conversation
It was added in 66f8997 to be compatible with Rack::ContentLength. However, to_ary was removed from Rack::Response in 2.1.0, and Rack::ContentLength stopped checking for response bodies to define to_ary in 2.2.0. In addition, Rack 3 will eventually require response bodies that define to_ary to have a proper return value. Since the minimum supported Rack version is already 2.2.0, to_ary can be safely removed now.
7 tasks
Contributor
|
Thanks for doing this! |
tenderlove
pushed a commit
that referenced
this pull request
Sep 23, 2022
Remove to_ary from RackBody
zzak
added a commit
to zzak/rails
that referenced
this pull request
Oct 13, 2023
There is an inherit complexity with wrapping the Rack body inside Rails which can lead to bugs, like rails#49588. While rails#49616 fixed the bug, it's probably not a good long-term solution. If we go all the way back to 6a89850, we can see this was the original behavior. However, we were trying to solve a separate issue with streaming bodies during disconnect. The `live_stream_test#test_abort_with_full_buffer` test fails in this PR, but I wanted to raise that maybe this could be handled a different way. Also there are two failures in `response_test` which are questions to me: * `ResponseTest#test_[response.to_a].flatten_does_not_recurse_infinitely` * `ResponseTest#test_compatibility_with_Rack::ContentLength` The first seems it is actually resolved upstream, per this comment: rails#47092 (comment) The second means we broke `Rack::ContentLength` and there is a bit on this in rails#44953. FWIW: I'm not proposing this PR exactly, but looking for a path forward and would love some feedback. 🙇
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.
Summary
It was added in 66f8997 to be compatible with
Rack::ContentLength.However,
to_arywas removed fromRack::Responsein 2.1.0, andRack::ContentLengthstopped checking for response bodies to defineto_aryin 2.2.0. In addition, Rack 3 will eventually require responsebodies that define
to_aryto have a proper return value.Since the minimum supported Rack version is already 2.2.0,
to_arycanbe safely removed now.
Other Information
to_aryremoved fromRack::Responsein Removeto_aryfrom Response rack/rack#1453to_arycheck removed fromRack::ContentLengthin Set Content-Length response header even for bodies not responding to to_ary rack/rack#1509body.to_aryis present rack/rack#1876