aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEdward Anderson <nilbus@nilbus.com>2013-01-12 10:33:01 -0500
committerEdward Anderson <nilbus@nilbus.com>2013-01-15 19:16:08 -0500
commit7925884b5e03127b40f4fd8987b8be115a406c4a (patch)
tree923562fb1525b21383000d7700eced6cd832e0a8
parent8492396e9c1fe21036783d9785ed42c27dee9201 (diff)
downloadrails-7925884b5e03127b40f4fd8987b8be115a406c4a.tar.gz
rails-7925884b5e03127b40f4fd8987b8be115a406c4a.tar.bz2
rails-7925884b5e03127b40f4fd8987b8be115a406c4a.zip
Remove header bloat introduced by BestStandardsSupport middleware
The same headers were being duplicated on every request.
-rw-r--r--actionpack/CHANGELOG.md5
-rw-r--r--actionpack/lib/action_dispatch/middleware/best_standards_support.rb4
-rw-r--r--actionpack/test/dispatch/best_standards_support_test.rb3
3 files changed, 10 insertions, 2 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md
index 4b15c5cb41..a3d2274b61 100644
--- a/actionpack/CHANGELOG.md
+++ b/actionpack/CHANGELOG.md
@@ -1,5 +1,10 @@
## Rails 4.0.0 (unreleased) ##
+* `BestStandardsSupport` no longer duplicates `X-UA-Compatible` values on
+ each request to prevent header size from blowing up.
+
+ *Edward Anderson*
+
* Change the behavior of route defaults so that explicit defaults are no longer
required where the key is not part of the path. For example:
diff --git a/actionpack/lib/action_dispatch/middleware/best_standards_support.rb b/actionpack/lib/action_dispatch/middleware/best_standards_support.rb
index d338996240..94efeb79fa 100644
--- a/actionpack/lib/action_dispatch/middleware/best_standards_support.rb
+++ b/actionpack/lib/action_dispatch/middleware/best_standards_support.rb
@@ -17,7 +17,9 @@ module ActionDispatch
status, headers, body = @app.call(env)
if headers["X-UA-Compatible"] && @header
- headers["X-UA-Compatible"] << "," << @header.to_s
+ unless headers["X-UA-Compatible"][@header]
+ headers["X-UA-Compatible"] << "," << @header.to_s
+ end
else
headers["X-UA-Compatible"] = @header
end
diff --git a/actionpack/test/dispatch/best_standards_support_test.rb b/actionpack/test/dispatch/best_standards_support_test.rb
index 0737c40a39..551bb9621a 100644
--- a/actionpack/test/dispatch/best_standards_support_test.rb
+++ b/actionpack/test/dispatch/best_standards_support_test.rb
@@ -16,9 +16,10 @@ class BestStandardsSupportTest < ActiveSupport::TestCase
assert_equal nil, headers["X-UA-Compatible"]
end
- def test_appends_to_app_headers
+ 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"]