Skip to content

Commit

Permalink
Honor */* in Accept headers correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
skade committed May 20, 2011
1 parent 70766a4 commit f1fdc23
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion padrino-core/lib/padrino-core/application/routing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ def provides(*types)

# per rfc2616-sec14:
# Assume */* if no ACCEPT header is given.
accepts.delete "*/*"
catch_all = (accepts.delete "*/*" || accepts.empty?)
if accepts.empty?
matching_types = mime_types.slice(0,1)
else
Expand All @@ -566,6 +566,9 @@ def provides(*types)
elsif !url_format && matching_types.first
type = ::Rack::Mime::MIME_TYPES.find { |k, v| v == matching_types.first }[0].sub(/\./,'').to_sym
accept_format = CONTENT_TYPE_ALIASES[type] || type
elsif catch_all
type = types.first
accept_format = CONTENT_TYPE_ALIASES[type] || type
end

matched_format = types.include?(:any) ||
Expand Down

0 comments on commit f1fdc23

Please sign in to comment.