Skip to content

Commit

Permalink
Allow ignore_accept_header through configuration option.
Browse files Browse the repository at this point in the history
  • Loading branch information
josevalim committed May 2, 2011
1 parent 73c94ed commit 83e35b9
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions actionpack/lib/action_dispatch/railtie.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ class Railtie < Rails::Railtie
config.action_dispatch.show_exceptions = true config.action_dispatch.show_exceptions = true
config.action_dispatch.best_standards_support = true config.action_dispatch.best_standards_support = true
config.action_dispatch.tld_length = 1 config.action_dispatch.tld_length = 1
config.action_dispatch.ignore_accept_header = false
config.action_dispatch.rack_cache = {:metastore => "rails:/", :entitystore => "rails:/", :verbose => true} config.action_dispatch.rack_cache = {:metastore => "rails:/", :entitystore => "rails:/", :verbose => true}


initializer "action_dispatch.configure" do |app| initializer "action_dispatch.configure" do |app|
ActionDispatch::Http::URL.tld_length = app.config.action_dispatch.tld_length ActionDispatch::Http::URL.tld_length = app.config.action_dispatch.tld_length
ActionDispatch::Request.ignore_accept_header = app.config.action_dispatch.ignore_accept_header
end end
end end
end end
21 changes: 21 additions & 0 deletions railties/test/application/configuration_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -442,5 +442,26 @@ def index


assert_equal [:json], ActionController::Base._wrapper_options[:format] assert_equal [:json], ActionController::Base._wrapper_options[:format]
end end

test "config.action_dispatch.ignore_accept_header" do
make_basic_app do |app|
app.config.action_dispatch.ignore_accept_header = true
end

class ::OmgController < ActionController::Base
def index
respond_to do |format|
format.html { render :text => "HTML" }
format.xml { render :text => "XML" }
end
end
end

get "/", {}, "HTTP_ACCEPT" => "application/xml"
assert_equal 'HTML', last_response.body

get "/", { :format => :xml }, "HTTP_ACCEPT" => "application/xml"
assert_equal 'XML', last_response.body
end
end end
end end

0 comments on commit 83e35b9

Please sign in to comment.