diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2012-08-09 13:38:29 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2012-08-09 13:38:29 -0700 |
commit | 6794e92b204572d75a07bd6413bdae6ae22d5a82 (patch) | |
tree | dfec13e94add6c7c181cda11b13f56a4b7e1baf1 /actionpack/lib | |
parent | 6a3d4695f043031b73b1f5bc218fbeeae9fff771 (diff) | |
parent | 98c18d0058a01e47f3acb10b3a105d79bd1597bf (diff) | |
download | rails-6794e92b204572d75a07bd6413bdae6ae22d5a82.tar.gz rails-6794e92b204572d75a07bd6413bdae6ae22d5a82.tar.bz2 rails-6794e92b204572d75a07bd6413bdae6ae22d5a82.zip |
Merge pull request #7302 from homakov/default_headers
Introduce default_headers. closes #6311 #6515
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/http/response.rb | 5 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/railtie.rb | 1 |
2 files changed, 6 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/http/response.rb b/actionpack/lib/action_dispatch/http/response.rb index d336808e7c..5014ad80aa 100644 --- a/actionpack/lib/action_dispatch/http/response.rb +++ b/actionpack/lib/action_dispatch/http/response.rb @@ -58,6 +58,7 @@ module ActionDispatch # :nodoc: LOCATION = "Location".freeze cattr_accessor(:default_charset) { "utf-8" } + cattr_accessor(:default_headers) include Rack::Response::Helpers include ActionDispatch::Http::Cache::Response @@ -96,6 +97,10 @@ module ActionDispatch # :nodoc: def initialize(status = 200, header = {}, body = []) super() + if self.class.default_headers.respond_to?(:merge) + header = self.class.default_headers.merge(header) + end + self.body, self.header, self.status = body, header, status @sending_file = false diff --git a/actionpack/lib/action_dispatch/railtie.rb b/actionpack/lib/action_dispatch/railtie.rb index 62f906219c..e7f3f07390 100644 --- a/actionpack/lib/action_dispatch/railtie.rb +++ b/actionpack/lib/action_dispatch/railtie.rb @@ -23,6 +23,7 @@ module ActionDispatch ActionDispatch::Http::URL.tld_length = app.config.action_dispatch.tld_length ActionDispatch::Request.ignore_accept_header = app.config.action_dispatch.ignore_accept_header ActionDispatch::Response.default_charset = app.config.action_dispatch.default_charset || app.config.encoding + ActionDispatch::Response.default_headers = app.config.action_dispatch.default_headers ActionDispatch::ExceptionWrapper.rescue_responses.merge!(config.action_dispatch.rescue_responses) ActionDispatch::ExceptionWrapper.rescue_templates.merge!(config.action_dispatch.rescue_templates) |