Ticket #8438: rewind_request_body.diff
| File rewind_request_body.diff, 1.4 kB (added by s450r1, 2 years ago) |
|---|
-
actionpack/test/controller/cgi_test.rb
old new 68 68 assert_equal({"flamenco"=> "love"}, @request.request_parameters) 69 69 end 70 70 end 71 72 73 class CgiRequestNeedsRewoundTest < BaseCgiTest 74 def test_body_should_be_rewound 75 data = 'foo' 76 fake_cgi = Struct.new(:env_table, :query_string, :stdinput).new(@request_hash, '', StringIO.new(data)) 77 fake_cgi.env_table['CONTENT_LENGTH'] = data.length 78 fake_cgi.env_table['CONTENT_TYPE'] = 'application/x-www-form-urlencoded; charset=utf-8' 79 request = ActionController::CgiRequest.new(fake_cgi) 80 request.request_parameters 81 assert_equal(0, request.body.pos) 82 end 83 end -
actionpack/lib/action_controller/request.rb
old new 330 330 331 331 # Only multipart form parsing expects a stream. 332 332 if strategy && strategy != :multipart_form 333 body = body.read(content_length) 333 data = body.read(content_length) 334 body.rewind if body.respond_to?(:rewind) 335 body = data 334 336 end 335 337 336 338 case strategy