2 # This class implements a simple way of constructing the HTTP headers dynamically
3 # via a Hash syntax. Think of it as a write-only Hash. Refer to HttpResponse for
4 # information on how this is used.
6 # One consequence of this write-only nature is that you can write multiple headers
7 # by just doing them twice (which is sometimes needed in HTTP), but that the normal
8 # semantics for Hash (where doing an insert replaces) is not there.
11 attr_accessor :allowed_duplicates
15 @allowed_duplicates = {"Set-Cookie" => true, "Set-Cookie2" => true,
16 "Warning" => true, "WWW-Authenticate" => true}
20 # Simply writes "#{key}: #{value}" to an output buffer.
22 if not @sent.has_key?(key) or @allowed_duplicates.has_key?(key)
24 @out.write(Const::HEADER_FORMAT % [key, value])