aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rwxr-xr-xactionpack/lib/action_controller/request.rb8
-rw-r--r--actionpack/test/controller/request_test.rb10
2 files changed, 17 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb
index a3eac357f7..785f6d424a 100755
--- a/actionpack/lib/action_controller/request.rb
+++ b/actionpack/lib/action_controller/request.rb
@@ -588,7 +588,13 @@ module ActionController
end
raise EOFError, "bad boundary end of body part" unless boundary_end=~/--/
- body.rewind if body.respond_to?(:rewind)
+ begin
+ body.rewind if body.respond_to?(:rewind)
+ rescue Errno::ESPIPE
+ # Handles exceptions raised by input streams that cannot be rewound
+ # such as when using plain CGI under Apache
+ end
+
params
end
end
diff --git a/actionpack/test/controller/request_test.rb b/actionpack/test/controller/request_test.rb
index 1ae1f975a0..76c8604c50 100644
--- a/actionpack/test/controller/request_test.rb
+++ b/actionpack/test/controller/request_test.rb
@@ -736,6 +736,16 @@ class MultipartRequestParameterParsingTest < Test::Unit::TestCase
assert ('a' * 20480) == file.read
end
+ uses_mocha "test_no_rewind_stream" do
+ def test_no_rewind_stream
+ # Ensures that parse_multipart_form_parameters works with streams that cannot be rewound
+ file = File.open(File.join(FIXTURE_PATH, 'large_text_file'), 'rb')
+ file.expects(:rewind).raises(Errno::ESPIPE)
+ params = ActionController::AbstractRequest.parse_multipart_form_parameters(file, 'AaB03x', file.stat.size, {})
+ assert_not_equal 0, file.pos # file was not rewound after reading
+ end
+ end
+
def test_binary_file
params = process('binary_file')
assert_equal %w(file flowers foo), params.keys.sort