diff options
Diffstat (limited to 'lib/mongrel/header_out.rb')
-rw-r--r-- | lib/mongrel/header_out.rb | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/lib/mongrel/header_out.rb b/lib/mongrel/header_out.rb deleted file mode 100644 index 008bff8..0000000 --- a/lib/mongrel/header_out.rb +++ /dev/null @@ -1,34 +0,0 @@ -module Mongrel - # 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 - attr_reader :out - attr_accessor :allowed_duplicates - - 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) - @sent[key] = true - @out.write(Const::HEADER_FORMAT % [key, value]) - end - end - end -end |