From 8f836f406ca10274c6465e17c2b5646257a8412b Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 10 Dec 2009 21:34:17 -0600 Subject: 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. Signed-off-by: Joshua Peek --- 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 280d89dd..dddf9694 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 0c1e1ca3..874c28cd 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 92c8c4a6..a7f9bf2b 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 -- cgit v1.2.3-24-ge0c7