Permalink
Browse files

set cached values in the env hash

  • Loading branch information...
tenderlove committed Aug 22, 2015
1 parent 7bd34c1 commit ec760e67fd9be26de165c912dfd0dd0f3f31b4b8
Showing with 9 additions and 6 deletions.
  1. +9 −6 actionpack/lib/action_dispatch/http/mime_negotiation.rb
@@ -15,12 +15,13 @@ module MimeNegotiation
# For backward compatibility, the post \format is extracted from the
# X-Post-Data-Format HTTP header if present.
def content_mime_type
get_header("action_dispatch.request.content_type") do
if get_header('CONTENT_TYPE') =~ /^([^,\;]*)/
get_header("action_dispatch.request.content_type") do |k|
v = if get_header('CONTENT_TYPE') =~ /^([^,\;]*)/
Mime::Type.lookup($1.strip.downcase)
else
nil
end
set_header k, v
end
end
@@ -30,14 +31,15 @@ def content_type
# Returns the accepted MIME type for the request.
def accepts
get_header("action_dispatch.request.accepts") do
get_header("action_dispatch.request.accepts") do |k|
header = get_header('HTTP_ACCEPT').to_s.strip
if header.empty?
v = if header.empty?
[content_mime_type]
else
Mime::Type.parse(header)
end
set_header k, v
end
end
@@ -52,14 +54,14 @@ def format(view_path = [])
end
def formats
get_header("action_dispatch.request.formats") do
get_header("action_dispatch.request.formats") do |k|
params_readable = begin
parameters[:format]
rescue ActionController::BadRequest
false
end
if params_readable
v = if params_readable
Array(Mime[parameters[:format]])
elsif use_accept_header && valid_accept_header
accepts
@@ -68,6 +70,7 @@ def formats
else
[Mime::HTML]
end
set_header k, v
end
end

0 comments on commit ec760e6

Please sign in to comment.