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. --- lib/unicorn/http_response.rb | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'lib/unicorn/http_response.rb') diff --git a/lib/unicorn/http_response.rb b/lib/unicorn/http_response.rb index 2d13863..c59ce2c 100644 --- a/lib/unicorn/http_response.rb +++ b/lib/unicorn/http_response.rb @@ -1,6 +1,4 @@ # -*- encoding: binary -*- -require 'time' - # Writes a Rack response to your client using the HTTP/1.1 specification. # You use it by simply doing: # @@ -25,7 +23,7 @@ module Unicorn::HttpResponse if headers buf = "HTTP/1.1 #{status}\r\n" \ - "Date: #{Time.now.httpdate}\r\n" \ + "Date: #{httpdate}\r\n" \ "Status: #{status}\r\n" \ "Connection: close\r\n" headers.each do |key, value| -- cgit v1.2.3-24-ge0c7