Changeset 3843
- Timestamp:
- 03/12/06 05:13:55 (2 years ago)
- Files:
-
- trunk/actionpack/lib/action_controller/mime_type.rb (modified) (1 diff)
- trunk/actionpack/lib/action_controller/request.rb (modified) (2 diffs)
- trunk/actionpack/test/controller/mime_responds_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/lib/action_controller/mime_type.rb
r3838 r3843 40 40 XML = Type.new "application/xml" 41 41 RSS = Type.new "application/rss+xml" 42 ATOM = Type.new "application/ rss+atom"42 ATOM = Type.new "application/atom+xml" 43 43 YAML = Type.new "application/x-yaml" 44 44 end trunk/actionpack/lib/action_controller/request.rb
r3838 r3843 52 52 53 53 @content_type = @env['CONTENT_TYPE'].to_s.downcase 54 54 55 55 if @env['HTTP_X_POST_DATA_FORMAT'] 56 56 case @env['HTTP_X_POST_DATA_FORMAT'].downcase.to_sym … … 66 66 67 67 def accepts 68 @accepts ||= (@env['HTTP_ACCEPT'].strip.blank? ? "*/*" : @env['HTTP_ACCEPT']).split(";").collect! do |mime_type| 69 Mime::Type.new(mime_type.strip) 68 return @accepts if @accepts 69 70 @accepts = if @env['HTTP_ACCEPT'].to_s.strip.blank? 71 [ content_type, Mime::ALL ] 72 else 73 @env['HTTP_ACCEPT'].split(";").collect! do |mime_type| 74 Mime::Type.new(mime_type.strip) 75 end 70 76 end 71 77 end trunk/actionpack/test/controller/mime_responds_test.rb
r3842 r3843 46 46 type.html 47 47 type.xml(person_in_xml) 48 end 49 end 50 51 def made_for_content_type 52 respond_to do |type| 53 type.rss { render :text => "RSS" } 54 type.atom { render :text => "ATOM" } 55 type.all { render :text => "Nothing" } 48 56 end 49 57 end … … 138 146 assert_equal "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<person>\n <name>David</name>\n</person>\n", @response.body 139 147 end 148 149 def test_with_content_type 150 @request.env["CONTENT_TYPE"] = "application/atom+xml" 151 get :made_for_content_type 152 assert_equal "ATOM", @response.body 153 154 @request.env["CONTENT_TYPE"] = "application/rss+xml" 155 get :made_for_content_type 156 assert_equal "RSS", @response.body 157 end 140 158 end