From 950b4ba1454543de492efffdf4022f481ca7e4c2 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 5 Jan 2011 16:14:07 -0800 Subject: response: use optimized httpdate implementation Believe it or not, Time#httpdate showed up at the top of my profiler output for the past couple of years now. I guess that's what happens when all HTTP applications I write are less complex than Rack::Lobster :P --- lib/rainbows/response.rb | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'lib/rainbows/response.rb') diff --git a/lib/rainbows/response.rb b/lib/rainbows/response.rb index b624ea2..9a46659 100644 --- a/lib/rainbows/response.rb +++ b/lib/rainbows/response.rb @@ -1,10 +1,7 @@ # -*- encoding: binary -*- # :enddoc: -require 'time' # for Time#httpdate - module Rainbows::Response - CRLF = Unicorn::HttpResponse::CRLF - CODES = Unicorn::HttpResponse::CODES + include Unicorn::HttpResponse Close = "close" KeepAlive = "keep-alive" @@ -22,7 +19,7 @@ module Rainbows::Response @hp.headers? or return status = CODES[status.to_i] || status buf = "HTTP/1.1 #{status}\r\n" \ - "Date: #{Time.now.httpdate}\r\n" \ + "Date: #{httpdate}\r\n" \ "Status: #{status}\r\n" \ "Connection: #{alive ? KeepAlive : Close}\r\n" headers.each do |key, value| -- cgit v1.2.3-24-ge0c7