Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8327

Show
Ignore:
Timestamp:
12/07/07 04:20:20 (1 year ago)
Author:
bitsweat
Message:

Ignore illegal seeks on body rewind. Catches CGI errors depending on your httpd. Closes #10404 [Curtis Hawthorne]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/lib/action_controller/request.rb

    r8314 r8327  
    589589          raise EOFError, "bad boundary end of body part" unless boundary_end=~/--/ 
    590590 
    591           body.rewind if body.respond_to?(:rewind) 
     591          begin 
     592            body.rewind if body.respond_to?(:rewind) 
     593          rescue Errno::ESPIPE 
     594            # Handles exceptions raised by input streams that cannot be rewound 
     595            # such as when using plain CGI under Apache 
     596          end 
     597 
    592598          params 
    593599        end 
  • trunk/actionpack/test/controller/request_test.rb

    r8235 r8327  
    737737  end 
    738738 
     739  uses_mocha "test_no_rewind_stream" do 
     740    def test_no_rewind_stream 
     741      # Ensures that parse_multipart_form_parameters works with streams that cannot be rewound 
     742      file = File.open(File.join(FIXTURE_PATH, 'large_text_file'), 'rb') 
     743      file.expects(:rewind).raises(Errno::ESPIPE) 
     744      params = ActionController::AbstractRequest.parse_multipart_form_parameters(file, 'AaB03x', file.stat.size, {}) 
     745      assert_not_equal 0, file.pos  # file was not rewound after reading 
     746    end 
     747  end 
     748 
    739749  def test_binary_file 
    740750    params = process('binary_file')