about summary refs log tree commit homepage
path: root/lib/unicorn/cgi_wrapper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/unicorn/cgi_wrapper.rb')
-rw-r--r--lib/unicorn/cgi_wrapper.rb18
1 files changed, 7 insertions, 11 deletions
diff --git a/lib/unicorn/cgi_wrapper.rb b/lib/unicorn/cgi_wrapper.rb
index bc622ea..b6eeb33 100644
--- a/lib/unicorn/cgi_wrapper.rb
+++ b/lib/unicorn/cgi_wrapper.rb
@@ -1,3 +1,5 @@
+# -*- encoding: binary -*-
+
 # This code is based on the original CGIWrapper from Mongrel
 # Copyright (c) 2005 Zed A. Shaw
 # Copyright (c) 2009 Eric Wong
@@ -44,7 +46,7 @@ class Unicorn::CGIWrapper < ::CGI
     'language' => 'Content-Language'.freeze,
     'expires' => 'Expires'.freeze,
     'length' => CONTENT_LENGTH,
-  }.freeze
+  }
 
   # Takes an a Rackable environment, plus any additional CGI.new
   # arguments These are used internally to create a wrapper around the
@@ -57,21 +59,20 @@ class Unicorn::CGIWrapper < ::CGI
     @status = nil
     @head = {}
     @headv = Hash.new { |hash,key| hash[key] = [] }
-    @body = StringIO.new
+    @body = StringIO.new("")
     super(*args)
   end
 
   # finalizes the response in a way Rack applications would expect
   def rack_response
     # @head[CONTENT_LENGTH] ||= @body.size
-    @headv[SET_COOKIE] += @output_cookies if @output_cookies
+    @headv[SET_COOKIE].concat(@output_cookies) if @output_cookies
     @headv.each_pair do |key,value|
       @head[key] ||= value.join("\n") unless value.empty?
     end
 
     # Capitalized "Status:", with human-readable status code (e.g. "200 OK")
-    parseable_status = @head.delete(Status)
-    @status ||= parseable_status.split(/ /)[0].to_i rescue 500
+    @status ||= @head.delete(Status)
 
     [ @status || 500, @head, [ @body.string ] ]
   end
@@ -136,13 +137,8 @@ class Unicorn::CGIWrapper < ::CGI
     @env_table[RACK_INPUT]
   end
 
-  # The stdoutput should be completely bypassed but we'll drop a
-  # warning just in case
+  # return a pointer to the StringIO body since it's STDOUT-like
   def stdoutput
-    err = @env_table[RACK_ERRORS]
-    err.puts "WARNING: Your program is doing something not expected."
-    err.puts "Please tell Eric that stdoutput was used and what software " \
-             "you are running.  Thanks."
     @body
   end