aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2015-09-22 16:20:19 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2015-09-22 16:20:27 -0700
commita9f28600e901b11a9222e34bfae8642bfb753186 (patch)
tree68760792098d0df97e7fd6f052e08fbb602316be
parent686897225e9d0372deac71a6dfdf881676bb3dea (diff)
downloadrails-a9f28600e901b11a9222e34bfae8642bfb753186.tar.gz
rails-a9f28600e901b11a9222e34bfae8642bfb753186.tar.bz2
rails-a9f28600e901b11a9222e34bfae8642bfb753186.zip
don't deal with `nil` values
We can know whether or not there is a content type object, and just exit early. There is no need to `try` so hard.
-rw-r--r--actionpack/lib/action_controller/metal/params_wrapper.rb4
-rw-r--r--actionpack/lib/action_dispatch/http/mime_negotiation.rb4
2 files changed, 7 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/metal/params_wrapper.rb b/actionpack/lib/action_controller/metal/params_wrapper.rb
index e680432127..c38fc40b81 100644
--- a/actionpack/lib/action_controller/metal/params_wrapper.rb
+++ b/actionpack/lib/action_controller/metal/params_wrapper.rb
@@ -276,7 +276,9 @@ module ActionController
# Checks if we should perform parameters wrapping.
def _wrapper_enabled?
- ref = request.content_mime_type.try(:ref)
+ return false unless request.has_content_type?
+
+ ref = request.content_mime_type.ref
_wrapper_formats.include?(ref) && _wrapper_key && !request.request_parameters[_wrapper_key]
end
end
diff --git a/actionpack/lib/action_dispatch/http/mime_negotiation.rb b/actionpack/lib/action_dispatch/http/mime_negotiation.rb
index 1a72ec847d..cfb96f5a2d 100644
--- a/actionpack/lib/action_dispatch/http/mime_negotiation.rb
+++ b/actionpack/lib/action_dispatch/http/mime_negotiation.rb
@@ -29,6 +29,10 @@ module ActionDispatch
content_mime_type && content_mime_type.to_s
end
+ def has_content_type?
+ has_header? 'CONTENT_TYPE'
+ end
+
# Returns the accepted MIME type for the request.
def accepts
fetch_header("action_dispatch.request.accepts") do |k|