From 771ee626338c8fa00f8eedda9bdfbbddb5206491 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 21 Mar 2009 19:29:44 -0700 Subject: Handle Rack multivalue headers correctly Rack uses a single newline character to represent multi-value headers. Thus { 'Set-Cookie' => "foo=bar\nbar=foo" } will get you: Set-Cookie: foo=bar Set-Cookie: bar=foo While RFC2616 says you can combine headers as: Set-Cookie: foo=bar,bar=foo There are probably HTTP clients out there that don't handle things correctly so don't bother... Additionally, don't bother doing duplicate suppression anymore. Just assume Rack or a higher layer knows what it's doing regarding duplicates and we'll get a Hash most of the time anyways. --- test/unit/test_response.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'test/unit/test_response.rb') diff --git a/test/unit/test_response.rb b/test/unit/test_response.rb index c30a141..4c7423b 100644 --- a/test/unit/test_response.rb +++ b/test/unit/test_response.rb @@ -41,5 +41,12 @@ class ResponseTest < Test::Unit::TestCase io.rewind assert_match(/.* #{HTTP_STATUS_CODES[code]}$/, io.readline.chomp, "wrong default reason phrase") end + + def test_rack_multivalue_headers + out = StringIO.new + HttpResponse.write(out,[200, {"X-Whatever" => "stuff\nbleh"}, []]) + assert_match(/^X-Whatever: stuff\r\nX-Whatever: bleh\r\n/, out.string) + end + end -- cgit v1.2.3-24-ge0c7