diff options
author | Matt Venables <mattvenables@gmail.com> | 2012-12-11 16:46:13 -0500 |
---|---|---|
committer | Matt Venables <mattvenables@gmail.com> | 2012-12-11 16:57:21 -0500 |
commit | 991601ff6e99139e7731212d5ac87385f943fb47 (patch) | |
tree | 4ea67e5aaca5628f84224b8a456d78da1dfd26f9 /actionpack/lib/action_dispatch | |
parent | 48583f8bf74d1cefefea3cd6591bd546a9eaff6c (diff) | |
download | rails-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/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/http/request.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/actionpack/lib/action_dispatch/http/request.rb b/actionpack/lib/action_dispatch/http/request.rb index 3de927abc8..d60c8775af 100644 --- a/actionpack/lib/action_dispatch/http/request.rb +++ b/actionpack/lib/action_dispatch/http/request.rb @@ -205,8 +205,9 @@ module ActionDispatch # work with raw requests directly. def raw_post unless @env.include? 'RAW_POST_DATA' - @env['RAW_POST_DATA'] = body.read(@env['CONTENT_LENGTH'].to_i) - body.rewind if body.respond_to?(:rewind) + raw_post_body = body + @env['RAW_POST_DATA'] = raw_post_body.read(@env['CONTENT_LENGTH'].to_i) + raw_post_body.rewind if raw_post_body.respond_to?(:rewind) end @env['RAW_POST_DATA'] end |