public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Search Repo:
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
jeremy (author)
Thu Dec 06 20:20:20 -0800 2007
commit  db885e81b9dc918a75bd66b1631a13e10447d0ff
tree    5f2c1f5f10e4769340f52db747f5f0369dd2f7f7
parent  2766f7629f318f0f7dadf2286113504113fef562
...
588
589
590
591
 
 
 
 
 
 
 
592
593
594
...
588
589
590
 
591
592
593
594
595
596
597
598
599
600
0
@@ -588,7 +588,13 @@
0
           end
0
           raise EOFError, "bad boundary end of body part" unless boundary_end=~/--/
0
 
0
- body.rewind if body.respond_to?(:rewind)
0
+ begin
0
+ body.rewind if body.respond_to?(:rewind)
0
+ rescue Errno::ESPIPE
0
+ # Handles exceptions raised by input streams that cannot be rewound
0
+ # such as when using plain CGI under Apache
0
+ end
0
+
0
           params
0
         end
0
     end
...
736
737
738
 
 
 
 
 
 
 
 
 
 
739
740
741
...
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
0
@@ -736,6 +736,16 @@
0
     assert ('a' * 20480) == file.read
0
   end
0
 
0
+ uses_mocha "test_no_rewind_stream" do
0
+ def test_no_rewind_stream
0
+ # Ensures that parse_multipart_form_parameters works with streams that cannot be rewound
0
+ file = File.open(File.join(FIXTURE_PATH, 'large_text_file'), 'rb')
0
+ file.expects(:rewind).raises(Errno::ESPIPE)
0
+ params = ActionController::AbstractRequest.parse_multipart_form_parameters(file, 'AaB03x', file.stat.size, {})
0
+ assert_not_equal 0, file.pos # file was not rewound after reading
0
+ end
0
+ end
0
+
0
   def test_binary_file
0
     params = process('binary_file')
0
     assert_equal %w(file flowers foo), params.keys.sort

Comments

    No one has commented yet.