Skip to content

Commit

Permalink
Prepare for mime type reordering depending on the branch [DHH]
Browse files Browse the repository at this point in the history
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3850 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information
dhh committed Mar 12, 2006
1 parent 09cec78 commit 60e4064
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 7 additions & 1 deletion actionpack/lib/action_controller/mime_type.rb
Expand Up @@ -3,6 +3,12 @@ class Type
def self.lookup(string) def self.lookup(string)
LOOKUP[string] LOOKUP[string]
end end

def self.parse(accept_header)
accept_header.split(",").collect! do |mime_type|
Mime::Type.lookup(mime_type.split(";").first.strip)
end
end


def initialize(string, symbol = nil, synonyms = []) def initialize(string, symbol = nil, synonyms = [])
@symbol, @synonyms = symbol, synonyms @symbol, @synonyms = symbol, synonyms
Expand Down Expand Up @@ -33,7 +39,7 @@ def ==(mime_type)
ALL = Type.new "*/*", :all ALL = Type.new "*/*", :all
HTML = Type.new "text/html", :html, %w( application/xhtml+xml ) HTML = Type.new "text/html", :html, %w( application/xhtml+xml )
JS = Type.new "text/javascript", :js, %w( application/javascript application/x-javascript ) JS = Type.new "text/javascript", :js, %w( application/javascript application/x-javascript )
XML = Type.new "application/xml", :xml, %w( text/xml application/x-xml ) XML = Type.new "application/xml", :xml, %w( application/x-xml )
RSS = Type.new "application/rss+xml", :rss RSS = Type.new "application/rss+xml", :rss
ATOM = Type.new "application/atom+xml", :atom ATOM = Type.new "application/atom+xml", :atom
YAML = Type.new "application/x-yaml", :yaml YAML = Type.new "application/x-yaml", :yaml
Expand Down
4 changes: 1 addition & 3 deletions actionpack/lib/action_controller/request.rb
Expand Up @@ -70,9 +70,7 @@ def accepts
@accepts = if @env['HTTP_ACCEPT'].to_s.strip.blank? @accepts = if @env['HTTP_ACCEPT'].to_s.strip.blank?
[ content_type, Mime::ALL ] [ content_type, Mime::ALL ]
else else
@env['HTTP_ACCEPT'].split(",").collect! do |mime_type| Mime::Type.parse(@env['HTTP_ACCEPT'])
Mime::Type.lookup(mime_type.split(";").first.strip)
end
end end
end end


Expand Down

0 comments on commit 60e4064

Please sign in to comment.