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

Changeset 4410

Show
Ignore:
Timestamp:
06/02/06 06:30:23 (2 years ago)
Author:
bitsweat
Message:

Rewind readable CGI params so others may reread them (such as CGI::Session when passing the session id in a multipart form). Closes #210.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r4406 r4410  
    11*SVN* 
     2 
     3* Rewind readable CGI params so others may reread them (such as CGI::Session when passing the session id in a multipart form).  #210 [mklame@atxeu.com, matthew@walker.wattle.id.au] 
    24 
    35* Added Mime::TEXT (text/plain) and Mime::ICS (text/calendar) as new default types [DHH] 
  • trunk/actionpack/lib/action_controller/cgi_ext/cgi_methods.rb

    r4344 r4410  
    184184      elsif value.respond_to?(:read) 
    185185        # Value as part of a multipart request 
    186         value.read 
     186        result = value.read 
     187        value.rewind 
     188        result 
    187189      elsif value.class == Array 
    188190        value.collect { |v| CGIMethods.get_typed_value(v) } 
  • trunk/actionpack/test/controller/cgi_test.rb

    r4388 r4410  
    304304  end 
    305305 
     306  # Rewind readable cgi params so others may reread them (such as CGI::Session 
     307  # when passing the session id in a multipart form). 
     308  def test_multipart_param_rewound 
     309    params = process('text_file') 
     310    assert_equal 'bar', @cgi.params['foo'][0].read 
     311  end 
     312 
    306313  private 
    307314    def process(name) 
     
    310317        ENV['CONTENT_LENGTH'] = file.stat.size.to_s 
    311318        $stdin = file 
    312         CGIMethods.parse_request_parameters CGI.new.params 
     319        @cgi = CGI.new 
     320        CGIMethods.parse_request_parameters @cgi.params 
    313321      end 
    314322    ensure