From a9f28600e901b11a9222e34bfae8642bfb753186 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 22 Sep 2015 16:20:19 -0700 Subject: 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. --- actionpack/lib/action_dispatch/http/mime_negotiation.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'actionpack/lib/action_dispatch/http') 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| -- cgit v1.2.3