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

Changeset 7126

Show
Ignore:
Timestamp:
06/26/07 01:19:18 (1 year ago)
Author:
bitsweat
Message:

Give the legacy X-POST_DATA_FORMAT header greater precedence during params parsing for backward compatibility.

Files:

Legend:

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

    r7096 r7126  
    11*SVN* 
     2 
     3* Give the legacy X-POST_DATA_FORMAT header greater precedence during params parsing for backward compatibility.  [Jeremy Kemper] 
    24 
    35* Fixed that link_to with an href of # when using :method will not allow for click-through without JavaScript #7037 [stevenbristol/josh] 
  • trunk/actionpack/lib/action_controller/request.rb

    r7005 r7126  
    6969    # X-Post-Data-Format HTTP header if present. 
    7070    def content_type 
    71       @content_type ||= 
    72         content_type_from_legacy_post_data_format_header || 
    73         Mime::Type.lookup(content_type_without_parameters) 
     71      @content_type ||= Mime::Type.lookup(content_type_without_parameters) 
    7472    end 
    7573 
     
    297295      # The raw content type string. Use when you need parameters such as 
    298296      # charset or boundary which aren't included in the content_type MIME type. 
     297      # Overridden by the X-POST_DATA_FORMAT header for backward compatibility. 
    299298      def content_type_with_parameters 
    300         env['CONTENT_TYPE'].to_s 
     299        content_type_from_legacy_post_data_format_header || 
     300          env['CONTENT_TYPE'].to_s 
    301301      end 
    302302 
     
    310310        if x_post_format = @env['HTTP_X_POST_DATA_FORMAT'] 
    311311          case x_post_format.to_s.downcase 
    312             when 'yaml';  Mime::YAML 
    313             when 'xml';   Mime::XML 
     312            when 'yaml';  'application/x-yaml' 
     313            when 'xml';   'application/xml' 
    314314          end 
    315315        end 
     
    320320 
    321321        content_type, boundary = self.class.extract_multipart_boundary(content_type_with_parameters) 
     322 
     323        # Don't parse params for unknown requests. 
    322324        return {} if content_type.blank? 
    323325 
  • trunk/actionpack/test/controller/request_test.rb

    r7005 r7126  
    759759    end 
    760760end 
     761 
     762class LegacyXmlParamsParsingTest < XmlParamsParsingTest 
     763  private 
     764    def parse_body(body) 
     765      env = { 'HTTP_X_POST_DATA_FORMAT' => 'xml', 
     766              'CONTENT_LENGTH' => body.size.to_s } 
     767      cgi = ActionController::Integration::Session::MockCGI.new(env, body) 
     768      ActionController::CgiRequest.new(cgi).request_parameters 
     769    end 
     770end