about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2010-04-18 21:24:07 -0700
committerEric Wong <normalperson@yhbt.net>2010-04-19 01:22:38 -0700
commitb6dcf1343a379f0fb5de5cc551dbbf85da2b4cdf (patch)
treeb0611aad629385db1d2192dd1f9ea9d8d2dbefb5 /lib
parentea36bb312bd9a35f9621d1cc406f8d07a37c2a2a (diff)
downloadrainbows-b6dcf1343a379f0fb5de5cc551dbbf85da2b4cdf.tar.gz
We can use the new HttpResponse.header_string method now
instead of writing an empty body.
Diffstat (limited to 'lib')
-rw-r--r--lib/rainbows/rev/deferred_response.rb21
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/rainbows/rev/deferred_response.rb b/lib/rainbows/rev/deferred_response.rb
index b69c7be..dd7a229 100644
--- a/lib/rainbows/rev/deferred_response.rb
+++ b/lib/rainbows/rev/deferred_response.rb
@@ -10,9 +10,13 @@ module Rainbows
       G = Rainbows::G
       HH = Rack::Utils::HeaderHash
 
-      def self.defer!(client, response, out)
-        body = response.last
-        headers = HH.new(response[1])
+      def self.write(client, response, out)
+        status, headers, body = response
+
+        body.respond_to?(:to_path) or
+            return HttpResponse.write(client, response, out)
+
+        headers = HH.new(headers)
 
         # to_io is not part of the Rack spec, but make an exception
         # here since we can't get here without checking to_path first
@@ -39,16 +43,11 @@ module Rainbows
           headers.delete('Transfer-Encoding')
           headers['Content-Length'] ||= st.size.to_s
         else # char/block device, directory, whatever... nobody cares
-          return response
+          return HttpResponse.write(client, response, out)
         end
         client.defer_body(io, out)
-        [ response.first, headers.to_hash, [] ]
-      end
-
-      def self.write(client, response, out)
-        response.last.respond_to?(:to_path) and
-          response = defer!(client, response, out)
-        HttpResponse.write(client, response, out)
+        out.nil? or
+          client.write(HttpResponse.header_string(status, headers.to_hash, out))
       end
 
       def initialize(io, client, do_chunk, body)