aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/request.rb
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2008-07-08 12:35:03 -0700
committerJeremy Kemper <jeremy@bitsweat.net>2008-07-09 10:42:30 -0700
commitf82bd31cb013cfba5bf3f5cad7356070fcefcc22 (patch)
tree00e9ae8a11ccad654619f02b339bd1cb9df708af /actionpack/lib/action_controller/request.rb
parenta6d0ae28e3ceef909f78afc27b936bca1e4b1021 (diff)
downloadrails-f82bd31cb013cfba5bf3f5cad7356070fcefcc22.tar.gz
rails-f82bd31cb013cfba5bf3f5cad7356070fcefcc22.tar.bz2
rails-f82bd31cb013cfba5bf3f5cad7356070fcefcc22.zip
Request#accepts special-cases a single mime type
Diffstat (limited to 'actionpack/lib/action_controller/request.rb')
-rwxr-xr-xactionpack/lib/action_controller/request.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/actionpack/lib/action_controller/request.rb b/actionpack/lib/action_controller/request.rb
index c76a93f7a1..7791e0696e 100755
--- a/actionpack/lib/action_controller/request.rb
+++ b/actionpack/lib/action_controller/request.rb
@@ -82,10 +82,16 @@ module ActionController
# Returns the accepted MIME type for the request
def accepts
@accepts ||=
- if @env['HTTP_ACCEPT'].to_s.strip.empty?
- [ content_type, Mime::ALL ].compact # make sure content_type being nil is not included
- else
- Mime::Type.parse(@env['HTTP_ACCEPT'])
+ begin
+ header = @env['HTTP_ACCEPT'].to_s.strip
+
+ if header.empty?
+ [content_type, Mime::ALL].compact
+ elsif header !~ /,/
+ [Mime::Type.lookup(header)].compact
+ else
+ Mime::Type.parse(header)
+ end
end
end