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

Reset CONTENT_LENGTH between test requests #32773

Merged
merged 1 commit into from May 1, 2018

Conversation

Projects
None yet
3 participants
@eugeneius
Member

eugeneius commented May 1, 2018

Followup to #32673.
Fixes #32767.

set_header "CONTENT_LENGTH", data_stream.length.to_s
set_header "rack.input", data_stream

If a POST request is followed by a GET request in a controller test, the rack.input and RAW_POST_DATA headers from the first request will be reset but the CONTENT_LENGTH header will leak, leading the request object in the second request to incorrectly believe it has a body.

r? @georgeclaghorn

Reset CONTENT_LENGTH between test requests
If a POST request is followed by a GET request in a controller test, the
`rack.input` and `RAW_POST_DATA` headers from the first request will be
reset but the `CONTENT_LENGTH` header will leak, leading the request
object in the second request to incorrectly believe it has a body.
@mmoll

This comment has been minimized.

mmoll commented May 1, 2018

I can confirm this indeed fixes GH-32767 🎉

@georgeclaghorn georgeclaghorn merged commit a42fb70 into rails:master May 1, 2018

2 checks passed

codeclimate All good!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

georgeclaghorn added a commit that referenced this pull request May 1, 2018

Merge pull request #32773 from eugeneius/content_length_multiple_requ…
…ests

Reset CONTENT_LENGTH between test requests
@georgeclaghorn

This comment has been minimized.

Member

georgeclaghorn commented May 1, 2018

Backported in 5699abf.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment