diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2009-05-24 17:35:49 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2009-05-24 17:35:49 -0700 |
commit | b1d4fb71bf890793133fab8e4226952865fd468b (patch) | |
tree | 3f1ef47ccf569fe2cdf01b6420607f1fe41a3ee3 /actionpack/lib/action_dispatch/http | |
parent | bdb61c1dadd64ad4e146228ac8048fd0034fa8cc (diff) | |
download | rails-b1d4fb71bf890793133fab8e4226952865fd468b.tar.gz rails-b1d4fb71bf890793133fab8e4226952865fd468b.tar.bz2 rails-b1d4fb71bf890793133fab8e4226952865fd468b.zip |
Construct a single HeaderHash. Speed up assign_default_content_type_and_charset
Diffstat (limited to 'actionpack/lib/action_dispatch/http')
-rw-r--r-- | actionpack/lib/action_dispatch/http/response.rb | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb index edb522ff49..a01114b730 100644 --- a/actionpack/lib/action_dispatch/http/response.rb +++ b/actionpack/lib/action_dispatch/http/response.rb @@ -41,8 +41,7 @@ module ActionDispatch # :nodoc: delegate :default_charset, :to => 'ActionController::Base' def initialize - super - @header = Rack::Utils::HeaderHash.new(DEFAULT_HEADERS) + super([], 200, DEFAULT_HEADERS) end # The response code of the request @@ -162,8 +161,15 @@ module ActionDispatch # :nodoc: end def assign_default_content_type_and_charset! - self.content_type ||= Mime::HTML - self.charset ||= default_charset unless sending_file? + if type = headers['Content-Type'] + unless type =~ /charset=/ || sending_file? + headers['Content-Type'] = "#{type}; charset=#{default_charset}" + end + else + type = Mime::HTML.to_s + type += "; charset=#{default_charset}" unless sending_file? + headers['Content-Type'] = type + end end def prepare! |