<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -588,7 +588,13 @@ module ActionController
           end
           raise EOFError, &quot;bad boundary end of body part&quot; 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>
      <filename>actionpack/lib/action_controller/request.rb</filename>
    </modified>
    <modified>
      <diff>@@ -736,6 +736,16 @@ class MultipartRequestParameterParsingTest &lt; Test::Unit::TestCase
     assert ('a' * 20480) == file.read
   end
 
+  uses_mocha &quot;test_no_rewind_stream&quot; 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</diff>
      <filename>actionpack/test/controller/request_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>2766f7629f318f0f7dadf2286113504113fef562</id>
    </parent>
  </parents>
  <author>
    <name>Jeremy Kemper</name>
    <email>jeremy@bitsweat.net</email>
  </author>
  <url>http://github.com/chriseppstein/rails/commit/db885e81b9dc918a75bd66b1631a13e10447d0ff</url>
  <id>db885e81b9dc918a75bd66b1631a13e10447d0ff</id>
  <committed-date>2007-12-06T20:20:20-08:00</committed-date>
  <authored-date>2007-12-06T20:20:20-08:00</authored-date>
  <message>Ignore illegal seeks on body rewind. Catches CGI errors depending on your httpd. Closes #10404 [Curtis Hawthorne]


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8327 5ecf4fe2-1ee6-0310-87b1-e25e094e27de</message>
  <tree>5f2c1f5f10e4769340f52db747f5f0369dd2f7f7</tree>
  <committer>
    <name>Jeremy Kemper</name>
    <email>jeremy@bitsweat.net</email>
  </committer>
</commit>
