From 95fa512342b4495cf9d56bbf663aa2114a85a4e1 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 16 Apr 2009 22:28:06 -0700 Subject: Small garbage reduction in HttpResponse Avoid creating new string objects and then discarding them right away by stuffing non-constant but always-present headers into the initial output. --- test/unit/test_response.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/unit/test_response.rb b/test/unit/test_response.rb index 8abc86c..1d47c57 100644 --- a/test/unit/test_response.rb +++ b/test/unit/test_response.rb @@ -60,7 +60,7 @@ class ResponseTest < Test::Unit::TestCase out = StringIO.new HttpResponse.write(out,[200, {"X-Whatever" => "stuff"}, []]) assert out.closed? - assert_match(/^Status: 200 OK\r\nX-Whatever: stuff\r\n/, out.string) + assert_equal 1, out.string.split(/\r\n/).grep(/^Status: 200 OK/i).size end # we always favor the code returned by the application, since "Status" @@ -71,7 +71,7 @@ class ResponseTest < Test::Unit::TestCase header_hash = {"X-Whatever" => "stuff", 'StaTus' => "666" } HttpResponse.write(out,[200, header_hash, []]) assert out.closed? - assert_match(/^Status: 200 OK\r\nX-Whatever: stuff\r\n/, out.string) + assert_equal 1, out.string.split(/\r\n/).grep(/^Status: 200 OK/i).size assert_equal 1, out.string.split(/\r\n/).grep(/^Status:/i).size end -- cgit v1.2.3-24-ge0c7