From 65192fa39480299f00a47cca661d20d889a008d1 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 4 Sep 2009 13:56:56 -0700 Subject: [PATCH 2/3] avoid HeaderHash#to_hash in middlewares Since HeaderHash objects are valid header responses, avoid converting the headers to Hash objects only to have it reconverted back to HeaderHash in the next middleware. --- lib/rack/chunked.rb | 4 ++-- lib/rack/content_type.rb | 2 +- lib/rack/response.rb | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/rack/chunked.rb b/lib/rack/chunked.rb index 280d89d..dddf969 100644 --- a/lib/rack/chunked.rb +++ b/lib/rack/chunked.rb @@ -19,7 +19,7 @@ module Rack STATUS_WITH_NO_ENTITY_BODY.include?(status) || headers['Content-Length'] || headers['Transfer-Encoding'] - [status, headers.to_hash, body] + [status, headers, body] else dup.chunk(status, headers, body) end @@ -29,7 +29,7 @@ module Rack @body = body headers.delete('Content-Length') headers['Transfer-Encoding'] = 'chunked' - [status, headers.to_hash, self] + [status, headers, self] end def each diff --git a/lib/rack/content_type.rb b/lib/rack/content_type.rb index 0c1e1ca..874c28c 100644 --- a/lib/rack/content_type.rb +++ b/lib/rack/content_type.rb @@ -17,7 +17,7 @@ module Rack status, headers, body = @app.call(env) headers = Utils::HeaderHash.new(headers) headers['Content-Type'] ||= @content_type - [status, headers.to_hash, body] + [status, headers, body] end end end diff --git a/lib/rack/response.rb b/lib/rack/response.rb index d1f6a12..1932c82 100644 --- a/lib/rack/response.rb +++ b/lib/rack/response.rb @@ -71,9 +71,9 @@ module Rack if [204, 304].include?(status.to_i) header.delete "Content-Type" - [status.to_i, header.to_hash, []] + [status.to_i, header, []] else - [status.to_i, header.to_hash, self] + [status.to_i, header, self] end end alias to_a finish # For *response -- 1.6.4.2.236.gf324c