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

Changeset 6340

Show
Ignore:
Timestamp:
03/05/07 18:24:17 (2 years ago)
Author:
xal
Message:

Ignore odd charset declaration in CONTENT_TYPE header which would throw off mime type lookup.

Files:

Legend:

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

    r6317 r6340  
    5959      @content_type ||= 
    6060        begin 
    61           content_type = @env['CONTENT_TYPE'].to_s.downcase 
     61          # Receive header sans any charset information. 
     62          content_type = @env['CONTENT_TYPE'].to_s.sub(/\s*\;.*$/, '').strip.downcase 
    6263           
    6364          if x_post_format = @env['HTTP_X_POST_DATA_FORMAT'] 
  • trunk/actionpack/test/controller/request_test.rb

    r5912 r6340  
    324324    assert_equal Mime::JS, @request.format 
    325325  end 
     326   
     327  def test_content_type 
     328    @request.env["CONTENT_TYPE"] = "text/html" 
     329    assert_equal Mime::HTML, @request.content_type 
     330  end 
     331 
     332  def test_content_no_type 
     333    assert_equal nil, @request.content_type 
     334  end 
     335   
     336  def test_content_type_xml 
     337    @request.env["CONTENT_TYPE"] = "application/xml" 
     338    assert_equal Mime::XML, @request.content_type 
     339  end 
     340 
     341  def test_content_type_with_charset 
     342    @request.env["CONTENT_TYPE"] = "application/xml; charset=UTF-8" 
     343    assert_equal Mime::XML, @request.content_type 
     344  end 
    326345 
    327346  protected