-
Notifications
You must be signed in to change notification settings - Fork 21.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't assume post with params will preserve input body. #47076
Conversation
I don't understand this change. I see that it's changing the tests to use |
The test code is exercising a feature in # Read the request \body. This is useful for web services that need to
# work with raw requests directly.
def raw_post
unless has_header? "RAW_POST_DATA"
raw_post_body = body
set_header("RAW_POST_DATA", raw_post_body.read(content_length))
raw_post_body.rewind if raw_post_body.respond_to?(:rewind)
end
get_header "RAW_POST_DATA"
end Submitting a request with By changing from Honestly, we should either move The goal of this PR is to make the minimum changes to preserve the existing semantics. So the test still exercises the |
@tenderlove any chance I can get your feedback on this PR? Thanks! cc @rafaelfranca another minor change to the tests to avoid running into "rewindable input" being removed in Rack 3. I would personally vote to remove |
@ioquatix the updated test in this PR
Also, I think you need to rebase, because upstream is now running tests for rack 2 + 3. |
If
|
To a certain extent, it's possible, but it's not guaranteed as it's no longer a requirement so any middleware that's inserted by the user could replace the input with a non-rewindable one and it would break again. |
debe60d
to
e7e554b
Compare
@hahmed I could not identify the problem you talked about:
Can you clarify what issue you were seeing? |
Rack 3 drops the requirement for input bodies to be rewindable, and params, once read, may not be available for "raw_post". Update the tests to prefer to use raw "body:" rather than "params:" which can be consumed by Rack::Request in Rack 3.
e7e554b
to
8db5160
Compare
@ioquatix Do you know if this PR is still required? There aren't any failing tests in actionpack with rack 3.0 in the main branch |
I'll check. |
It looks like this is no longer required to make the tests pass, so I'll close it. However, I think the tests are mixing up too many concepts. I don't think query serialisation and deserialisation belongs as part of the tests. I think this PR is still a good idea - it simplifies the tests to focus on what the test says it is testing and not parameter/query handling. If serialisation and deserialization should be tested in this regard, it should probably rename the tests or have separate tests. |
@ioquatix I think you're right, even when the tests are passing the name of the tests doesn't coincide with the code being tested, I'll check into this later this week. |
Rack 3 drops the requirement for input bodies to be rewindable, and params, once read, may not be available for "raw_post". Update the tests to prefer to use raw "body:" rather than "params:" which can be consumed by
Rack::Request
in Rack 3.