Permalink
Browse files

Remove BestStandardsSupport middleware

  • Loading branch information...
1 parent 88e4ec6 commit 3bccd12373567bf9369f44522599b7d61a006f60 @guilleiguaran guilleiguaran committed Jan 28, 2013
@@ -47,7 +47,6 @@ class IllegalStateError < StandardError
autoload_under 'middleware' do
autoload :RequestId
- autoload :BestStandardsSupport
autoload :Callbacks
autoload :Cookies
autoload :DebugExceptions
@@ -1,30 +0,0 @@
-module ActionDispatch
- class BestStandardsSupport
- def initialize(app, type = true)
- @app = app
-
- @header = case type
- when true
- "IE=Edge,chrome=1"
- when :builtin
- "IE=Edge"
- when false
- nil
- end
- end
-
- def call(env)
- status, headers, body = @app.call(env)
-
- if headers["X-UA-Compatible"] && @header
- unless headers["X-UA-Compatible"][@header]
- headers["X-UA-Compatible"] << "," << @header.to_s
- end
- else
- headers["X-UA-Compatible"] = @header
- end
-
- [status, headers, body]
- end
- end
-end
@@ -6,7 +6,6 @@ class Railtie < Rails::Railtie # :nodoc:
config.action_dispatch.x_sendfile_header = nil
config.action_dispatch.ip_spoofing_check = true
config.action_dispatch.show_exceptions = true
- config.action_dispatch.best_standards_support = true
config.action_dispatch.tld_length = 1
config.action_dispatch.ignore_accept_header = false
config.action_dispatch.rescue_templates = { }
@@ -1,35 +0,0 @@
-require 'abstract_unit'
-
-class BestStandardsSupportTest < ActiveSupport::TestCase
- def test_with_best_standards_support
- _, headers, _ = app(true, {}).call({})
- assert_equal "IE=Edge,chrome=1", headers["X-UA-Compatible"]
- end
-
- def test_with_builtin_best_standards_support
- _, headers, _ = app(:builtin, {}).call({})
- assert_equal "IE=Edge", headers["X-UA-Compatible"]
- end
-
- def test_without_best_standards_support
- _, headers, _ = app(false, {}).call({})
- assert_equal nil, headers["X-UA-Compatible"]
- end
-
- def test_appends_to_app_headers_without_duplication_after_multiple_requests
- app_headers = { "X-UA-Compatible" => "requiresActiveX=true" }
- _, headers, _ = app(true, app_headers).call({})
- _, headers, _ = app(true, app_headers).call({})
-
- expects = "requiresActiveX=true,IE=Edge,chrome=1"
- assert_equal expects, headers["X-UA-Compatible"]
- end
-
- private
-
- def app(type, headers)
- app = proc { [200, headers, "response"] }
- ActionDispatch::BestStandardsSupport.new(app, type)
- end
-
-end
@@ -365,10 +365,6 @@ def default_middleware_stack #:nodoc:
middleware.use ::Rack::Head
middleware.use ::Rack::ConditionalGet
middleware.use ::Rack::ETag, "no-cache"
-
- if config.action_dispatch.best_standards_support
- middleware.use ::ActionDispatch::BestStandardsSupport, config.action_dispatch.best_standards_support
- end
end
end
@@ -27,11 +27,11 @@ module Configuration
#
# Middlewares can also be completely swapped out and replaced with others:
#
- # config.middleware.swap ActionDispatch::BestStandardsSupport, Magical::Unicorns
+ # config.middleware.swap ActionDispatch::Flash, Magical::Unicorns
#
# And finally they can also be removed from the stack completely:
#
- # config.middleware.delete ActionDispatch::BestStandardsSupport
+ # config.middleware.delete ActionDispatch::Flash
#
class MiddlewareStackProxy
def initialize
@@ -19,9 +19,6 @@
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log
- # Only use best-standards-support built into browsers.
- config.action_dispatch.best_standards_support = :builtin
-
<%- unless options.skip_active_record? -%>
# Log the query plan for queries taking more than this (works
# with SQLite, MySQL, and PostgreSQL).
@@ -1,30 +0,0 @@
-require 'isolation/abstract_unit'
-
-module ApplicationTests
- class BestPracticesTest < ActiveSupport::TestCase
- include ActiveSupport::Testing::Isolation
-
- def setup
- build_app
- boot_rails
- require 'rack/test'
- extend Rack::Test::Methods
- simple_controller
- end
-
- def teardown
- teardown_app
- end
-
- test "simple controller in production mode returns best standards" do
- get '/foo'
- assert_equal "IE=Edge,chrome=1", last_response.headers["X-UA-Compatible"]
- end
-
- test "simple controller in development mode leaves out Chrome" do
- app("development")
- get "/foo"
- assert_equal "IE=Edge", last_response.headers["X-UA-Compatible"]
- end
- end
-end
@@ -45,8 +45,7 @@ def app
"ActionDispatch::ParamsParser",
"Rack::Head",
"Rack::ConditionalGet",
- "Rack::ETag",
- "ActionDispatch::BestStandardsSupport"
+ "Rack::ETag"
], middleware
end

7 comments on commit 3bccd12

Contributor

rubys replied Jun 13, 2013

👍

Contributor

jfirebaugh replied Nov 14, 2013

👎 Without this, the UI for switching to a non-standards compatibility mode is still provided, and I have encountered users who got into a bad mode accidentally, breaking the site, and didn't know how to fix it.

Owner

rafaelfranca replied Nov 14, 2013

You can set this header manually.

config.action_dispatch.default_headers = {
  "X-UA-Compatible" => "IE=Edge,chrome=1"
}
Owner

guilleiguaran replied Nov 14, 2013

@jfirebaugh this wasn't completely removed, was just moved to the set of default headers (config.action_dispatch.default_headers) since we don't want to have a middleware just to add a header.

Contributor

jfirebaugh replied Nov 14, 2013

Thanks for the pointer. The default default_headers results in X-UA-Compatible: chrome=1. I would say it should be X-UA-Compatible: IE=Edge,chrome=1, to match Rails 3 behavior and eliminate the possibility of the user accidentally switching to a non-standards compatibility mode.

Owner

rafaelfranca replied Nov 14, 2013

@jfirebaugh unfortunately we can't change it again now or it will break people application that expect only chrome=1

It's worth noting that because of the removal of IE=Edge certain users may now be served pages in compatibility mode because of their intranet settings. In our case it renders pages in IE7 compatibility mode. The only way to work-around these intranet enforcements is by explicitly adding IE=Edge back.

Please sign in to comment.