From 1835c9e2e12e6674b52dd80e4598cad9c4ea1e84 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 22 Mar 2009 21:09:08 -0700 Subject: HttpResponse: speed up non-multivalue headers The extra split slows things down a little as as it generates an array with a new string value and adds an extra loop to iterate through. --- lib/unicorn/http_response.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/unicorn/http_response.rb b/lib/unicorn/http_response.rb index c8aa3f9..f928baa 100644 --- a/lib/unicorn/http_response.rb +++ b/lib/unicorn/http_response.rb @@ -35,7 +35,11 @@ module Unicorn # the time anyways so just hope our app knows what it's doing headers.each do |key, value| next if SKIP.include?(key.downcase) - value.split(/\n/).each { |v| out << "#{key}: #{v}" } + if value =~ /\n/ + value.split(/\n/).each { |v| out << "#{key}: #{v}" } + else + out << "#{key}: #{value}" + end end # Rack should enforce Content-Length or chunked transfer encoding, -- cgit v1.2.3-24-ge0c7