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

Changeset 1336

Show
Ignore:
Timestamp:
05/20/05 18:32:04 (3 years ago)
Author:
david
Message:

Made the post_format work with content-type

Files:

Legend:

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

    r1334 r1336  
    1919* Added accessors to logger, params, response, session, flash, and headers from the view, so you can write <% logger.info "stuff" %> instead of <% @logger.info "others" %> -- more consistent with the preferred way of accessing these attributes and collections from the controller 
    2020 
    21 * Added support for POST data in form of YAML or XML, which is controller through the X-POST_DATA_MARSHAL header. Example request: 
    22  
    23     X-POST_DATA_MARSHAL: xml 
     21* Added support for POST data in form of YAML or XML, which is controller through the Content-Type header. Example request: 
     22 
     23    Content-Type: application/xml 
    2424    <request><item><content>HelloWorld</content></item></request> 
    2525   
    2626  ...is the same as: 
    2727 
    28     X-POST_DATA_MARSHAL: yaml 
     28    Content-Type: application/x-yaml 
    2929    --- 
    3030    item: 
     
    3939  Example Curl call: 
    4040 
    41     curl -H 'X-POST_DATA_MARSHAL: xml' -d '<request><item><content>KillMeMore</content></item></request>' http://www.example.com/service 
     41    curl -H 'Content-Type: application/xml' -d '<request><item><content>KillMeMore</content></item></request>' http://www.example.com/service 
    4242 
    4343  You can query to find out whether a given request came through as one of these types with: 
    44     - request.post_format? (:query_string, :xml or :yaml) 
     44    - request.post_format? (:url_encoded, :xml or :yaml) 
    4545    - request.formatted_post? (for either xml or yaml) 
    4646    - request.xml_post? 
  • trunk/actionpack/lib/action_controller/cgi_process.rb

    r1305 r1336  
    6464 
    6565    def request_parameters 
    66       if env['HTTP_X_POST_DATA_FORMAT'] 
    67         CGIMethods.parse_formatted_request_parameters(env['HTTP_X_POST_DATA_FORMAT'].downcase.intern, env['RAW_POST_DATA']) 
     66      if formatted_post? 
     67        CGIMethods.parse_formatted_request_parameters(post_format, env['RAW_POST_DATA']) 
    6868      else 
    6969        CGIMethods.parse_request_parameters(@cgi.params) 
  • trunk/actionpack/lib/action_controller/request.rb

    r1325 r1336  
    44    # Returns both GET and POST parameters in a single hash. 
    55    def parameters 
    6       # puts "#{request_parameters.inspect} | #{query_parameters.inspect} | #{path_parameters.inspect}" 
    76      @parameters ||= request_parameters.merge(query_parameters).merge(path_parameters).with_indifferent_access 
    87    end 
     
    3736        env['HTTP_X_POST_DATA_FORMAT'].downcase.intern 
    3837      else 
    39         :query_string 
     38        case env['HTTP_CONTENT_TYPE'] 
     39          when 'application/xml', 'text/xml' 
     40            :xml 
     41          when 'application/x-yaml', 'text/x-yaml' 
     42            :yaml 
     43          else 
     44            :url_encoded 
     45        end 
    4046      end 
    4147    end