aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/header_test.rb
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2013-03-13 16:25:28 +0100
committerYves Senn <yves.senn@gmail.com>2013-03-13 16:41:00 +0100
commita709246d1739c44e04b00412e7a4ec09c1500fc3 (patch)
tree8501c646a7ab409762e9f924a7bef9684e201c12 /actionpack/test/dispatch/header_test.rb
parent9af59b2468e4ad6c3c2ca89f90968fdcaa417aba (diff)
downloadrails-a709246d1739c44e04b00412e7a4ec09c1500fc3.tar.gz
rails-a709246d1739c44e04b00412e7a4ec09c1500fc3.tar.bz2
rails-a709246d1739c44e04b00412e7a4ec09c1500fc3.zip
`Http::Headers` respects dotted env vars, symbols, headers with numbers.
Diffstat (limited to 'actionpack/test/dispatch/header_test.rb')
-rw-r--r--actionpack/test/dispatch/header_test.rb27
1 files changed, 27 insertions, 0 deletions
diff --git a/actionpack/test/dispatch/header_test.rb b/actionpack/test/dispatch/header_test.rb
index 0bfc18b4ed..3bb3b3db23 100644
--- a/actionpack/test/dispatch/header_test.rb
+++ b/actionpack/test/dispatch/header_test.rb
@@ -38,6 +38,13 @@ class HeaderTest < ActiveSupport::TestCase
assert_equal "127.0.0.1", @headers["HTTP_HOST"]
end
+ test "headers can contain numbers" do
+ @headers["Content-MD5"] = "Q2hlY2sgSW50ZWdyaXR5IQ=="
+
+ assert_equal "Q2hlY2sgSW50ZWdyaXR5IQ==", @headers["Content-MD5"]
+ assert_equal "Q2hlY2sgSW50ZWdyaXR5IQ==", @headers["HTTP_CONTENT_MD5"]
+ end
+
test "set new env variables" do
@headers["HTTP_HOST"] = "127.0.0.1"
@@ -97,4 +104,24 @@ class HeaderTest < ActiveSupport::TestCase
assert_equal({"CONTENT_TYPE" => "text/plain",
"HTTP_REFERER" => "/some/page"}, @headers.env)
end
+
+ test "env variables with . are not modified" do
+ headers = ActionDispatch::Http::Headers.new
+ headers.merge! "rack.input" => "",
+ "rack.request.cookie_hash" => "",
+ "action_dispatch.logger" => ""
+
+ assert_equal(["action_dispatch.logger",
+ "rack.input",
+ "rack.request.cookie_hash"], headers.env.keys.sort)
+ end
+
+ test "symbols are treated as strings" do
+ headers = ActionDispatch::Http::Headers.new(:SERVER_NAME => "example.com",
+ "HTTP_REFERER" => "/",
+ :Host => "test.com")
+ assert_equal "example.com", headers["SERVER_NAME"]
+ assert_equal "/", headers[:HTTP_REFERER]
+ assert_equal "test.com", headers["HTTP_HOST"]
+ end
end