about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorIan Ownbey <imownbey@gmail.com>2008-11-22 18:20:46 -0800
committerIan Ownbey <imownbey@gmail.com>2008-11-22 18:20:46 -0800
commit18ac0fcc47f5533d695d629ca60f6d8cd2befd3f (patch)
tree9b1387e46e739d33d811dbf287f2d4dfe269fe98 /lib
parent01a76eb1ddc67dda21cc2646dc73c15830cb3de7 (diff)
downloadunicorn-18ac0fcc47f5533d695d629ca60f6d8cd2befd3f.tar.gz
Diffstat (limited to 'lib')
-rw-r--r--lib/mongrel/header_out.rb10
-rw-r--r--lib/mongrel/http_response.rb15
2 files changed, 15 insertions, 10 deletions
diff --git a/lib/mongrel/header_out.rb b/lib/mongrel/header_out.rb
index b34e95e..008bff8 100644
--- a/lib/mongrel/header_out.rb
+++ b/lib/mongrel/header_out.rb
@@ -10,13 +10,19 @@ module Mongrel
     attr_reader :out
     attr_accessor :allowed_duplicates
 
-    def initialize(out)
+    def initialize(out = StringIO.new)
       @sent = {}
       @allowed_duplicates = {"Set-Cookie" => true, "Set-Cookie2" => true,
         "Warning" => true, "WWW-Authenticate" => true}
       @out = out
     end
 
+    def merge!(hash)
+      hash.each do |key, value|
+        self[key] = value
+      end
+    end
+
     # Simply writes "#{key}: #{value}" to an output buffer.
     def[]=(key,value)
       if not @sent.has_key?(key) or @allowed_duplicates.has_key?(key)
@@ -25,4 +31,4 @@ module Mongrel
       end
     end
   end
-end \ No newline at end of file
+end
diff --git a/lib/mongrel/http_response.rb b/lib/mongrel/http_response.rb
index 08d4d75..bda2ed3 100644
--- a/lib/mongrel/http_response.rb
+++ b/lib/mongrel/http_response.rb
@@ -39,14 +39,15 @@ module Mongrel
     attr_reader :header_sent
     attr_reader :status_sent
 
-    def initialize(socket, app_responce)
+    def initialize(socket, app_response)
       @socket = socket
-      @app_responce = app_responce
-      @body = app_responce[2]
-      @status = app_responce[0]
+      @app_response = app_response
+      @body = StringIO.new(app_response[2].join(''))
+      @status = app_response[0]
       @reason = nil
-      @header = HeaderOut.new(app_responce[1])
+      @header = HeaderOut.new
       @header[Const::DATE] = Time.now.httpdate
+      @header.merge!(app_response[1])
       @body_sent = false
       @header_sent = false
       @status_sent = false
@@ -62,9 +63,7 @@ module Mongrel
     # all done.
     # TODO: docs
     def start #(status=200, finalize=false, reason=nil)
-      @reason = nil # TODO take this out
-      out.write(@body)
-      finished if finalize
+      finished
     end
 
     # Primarily used in exception handling to reset the response output in order to write