From 25bbb88bcc16c1c0a10efc99472b05e9f6b45861 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 6 Feb 2009 14:52:10 -0800 Subject: Get rid of HeaderOut and simplify HttpResponse Just stuff what little logic we had for it into HttpResponse since Rack takes care of the rest for us. Put the HTTP_STATUS_HEADERS hash in HttpResponse since we're the only user of it. Also, change HttpResponse.send to HttpResponse.write to avoid overriding the default method. --- lib/unicorn/header_out.rb | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) delete mode 100644 lib/unicorn/header_out.rb (limited to 'lib/unicorn/header_out.rb') diff --git a/lib/unicorn/header_out.rb b/lib/unicorn/header_out.rb deleted file mode 100644 index 95f2633..0000000 --- a/lib/unicorn/header_out.rb +++ /dev/null @@ -1,47 +0,0 @@ -module Unicorn - # This class implements a simple way of constructing the HTTP headers dynamically - # via a Hash syntax. Think of it as a write-only Hash. Refer to HttpResponse for - # information on how this is used. - # - # One consequence of this write-only nature is that you can write multiple headers - # by just doing them twice (which is sometimes needed in HTTP), but that the normal - # semantics for Hash (where doing an insert replaces) is not there. - class HeaderOut - ALLOWED_DUPLICATES = { - 'Set-Cookie' => true, - 'Set-Cookie2' => true, - 'Warning' => true, - 'WWW-Authenticate' => true, - }.freeze - - def initialize - @sent = { Const::CONNECTION => true } - @out = [] - end - - def reset! - @sent.clear - @out.clear - @sent[Const::CONNECTION] = true - 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) - @sent[key] = true - @out << "#{key}: #{value}\r\n" - end - end - - def to_s - @out.join - end - - end -end -- cgit v1.2.3-24-ge0c7