aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch
diff options
context:
space:
mode:
authorMatt Venables <mattvenables@gmail.com>2012-12-11 16:46:13 -0500
committerMatt Venables <mattvenables@gmail.com>2012-12-11 16:57:21 -0500
commit991601ff6e99139e7731212d5ac87385f943fb47 (patch)
tree4ea67e5aaca5628f84224b8a456d78da1dfd26f9 /actionpack/test/dispatch
parent48583f8bf74d1cefefea3cd6591bd546a9eaff6c (diff)
downloadrails-991601ff6e99139e7731212d5ac87385f943fb47.tar.gz
rails-991601ff6e99139e7731212d5ac87385f943fb47.tar.bz2
rails-991601ff6e99139e7731212d5ac87385f943fb47.zip
Fix rewinding in ActionDispatch::Request#raw_post
If env['RAW_POST_DATA'] is nil, #raw_post will attempt to set it to the result of #body (which will return env['rack.input'] if env['RAW_POST_DATA'] is nil). #raw_post will then attempt to rewind the result of another call to #body. Since env['RAW_POST_DATA'] has already been set, the result of #body is not env['rack.input'] anymore. This causes env['rack.input'] to never be rewound.
Diffstat (limited to 'actionpack/test/dispatch')
-rw-r--r--actionpack/test/dispatch/request_test.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/request_test.rb b/actionpack/test/dispatch/request_test.rb
index f2bacf3e20..263853fb6c 100644
--- a/actionpack/test/dispatch/request_test.rb
+++ b/actionpack/test/dispatch/request_test.rb
@@ -650,6 +650,13 @@ class RequestTest < ActiveSupport::TestCase
assert_equal Mime::XML, request.negotiate_mime([Mime::XML, Mime::CSV])
end
+ test "raw_post rewinds rack.input if RAW_POST_DATA is nil" do
+ request = stub_request('rack.input' => StringIO.new("foo"),
+ 'CONTENT_LENGTH' => 3)
+ assert_equal "foo", request.raw_post
+ assert_equal "foo", request.env['rack.input'].read
+ end
+
test "process parameter filter" do
test_hashes = [
[{'foo'=>'bar'},{'foo'=>'bar'},%w'food'],