From e21939d776673b2f8887adf7a5c64812b7d2e98e Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 30 Dec 2010 08:33:15 +0000 Subject: globally refactor Range handling for responses Rack::Utils::HeaderHash is still very expensive in Rack 1.2, especially for simple things that we want to run as fast as possible with minimal interference. HeaderHash is unnecessary for most requests that do not send Content-Range in responses. --- lib/rainbows/ev_core.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/rainbows/ev_core.rb') diff --git a/lib/rainbows/ev_core.rb b/lib/rainbows/ev_core.rb index 60fbdca..471f6a3 100644 --- a/lib/rainbows/ev_core.rb +++ b/lib/rainbows/ev_core.rb @@ -36,14 +36,15 @@ module Rainbows::EvCore end # returns whether to enable response chunking for autochunk models - def stream_response_headers(status, headers) + def stream_response_headers(status, headers, alive) + headers = Rack::Utils::HeaderHash.new(headers) if headers['Content-Length'] rv = false else rv = !!(headers['Transfer-Encoding'] =~ %r{\Achunked\z}i) rv = false if headers.delete('X-Rainbows-Autochunk') == 'no' end - write(response_header(status, headers)) + write_headers(status, headers, alive) rv end -- cgit v1.2.3-24-ge0c7