From bf680b1a61ab17b6a0e17432fd4ab22358ec83bd Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 5 Feb 2009 14:11:09 -0800 Subject: Remove StringIO usage in HeaderOut It's more GC-friendly to just use an array than to repeatedly append short strings on top of each other. I also find StringIO confusing... --- lib/unicorn/http_response.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'lib/unicorn/http_response.rb') diff --git a/lib/unicorn/http_response.rb b/lib/unicorn/http_response.rb index 5fbc990..c3094cf 100644 --- a/lib/unicorn/http_response.rb +++ b/lib/unicorn/http_response.rb @@ -77,8 +77,7 @@ module Unicorn raise "You have already sent the request headers." else # XXX Dubious ( http://mongrel.rubyforge.org/ticket/19 ) - @header.out.close - @header = HeaderOut.new(StringIO.new) + @header.reset! @body.close @body = StringIO.new @@ -95,8 +94,7 @@ module Unicorn def send_header if not @header_sent - @header.out.rewind - write(@header.out.read + Const::LINE_END) + write("#{@header.to_s}#{Const::LINE_END}") @header_sent = true end end -- cgit v1.2.3-24-ge0c7