From d100025759450dd1cbeccd1a3e44c46921bba26b Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Tue, 4 Jan 2011 17:50:51 -0800 Subject: http_response: implement httpdate in C This can return a static string and be significantly faster as it reduces object allocations and Ruby method calls for the fastest websites that serve thousands of requests a second. It assumes the Ruby runtime is single-threaded, but that is the case of Ruby 1.8 and 1.9 and also what Unicorn is all about. This change is safe for Rainbows! under 1.8 and 1.9. --- test/unit/test_response.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test') diff --git a/test/unit/test_response.rb b/test/unit/test_response.rb index 7dcf977..ac549bc 100644 --- a/test/unit/test_response.rb +++ b/test/unit/test_response.rb @@ -7,12 +7,23 @@ # for more information. require 'test/test_helper' +require 'time' include Unicorn class ResponseTest < Test::Unit::TestCase include Unicorn::HttpResponse + def test_httpdate + before = Time.now.to_i + str = httpdate + assert_kind_of(String, str) + middle = Time.parse(str).to_i + after = Time.now.to_i + assert before <= middle + assert middle <= after + end + def test_response_headers out = StringIO.new http_response_write(out,[200, {"X-Whatever" => "stuff"}, ["cool"]]) -- cgit v1.2.3-24-ge0c7