Class Mongrel::HeaderOut
In: lib/mongrel/header_out.rb
lib/mongrel/header_out.rb
Parent: Object

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.

Methods

[]=   []=   new   new  

Attributes

allowed_duplicates  [RW] 
allowed_duplicates  [RW] 
out  [R] 
out  [R] 

Public Class methods

[Source]

    # File lib/mongrel/header_out.rb, line 13
13:     def initialize(out)
14:       @sent = {}
15:       @allowed_duplicates = {"Set-Cookie" => true, "Set-Cookie2" => true,
16:         "Warning" => true, "WWW-Authenticate" => true}
17:       @out = out
18:     end

[Source]

    # File lib/mongrel/header_out.rb, line 13
13:     def initialize(out)
14:       @sent = {}
15:       @allowed_duplicates = {"Set-Cookie" => true, "Set-Cookie2" => true,
16:         "Warning" => true, "WWW-Authenticate" => true}
17:       @out = out
18:     end

Public Instance methods

Simply writes "#{key}: #{value}" to an output buffer.

[Source]

    # File lib/mongrel/header_out.rb, line 21
21:     def[]=(key,value)
22:       if not @sent.has_key?(key) or @allowed_duplicates.has_key?(key)
23:         @sent[key] = true
24:         @out.write(Const::HEADER_FORMAT % [key, value])
25:       end
26:     end

Simply writes "#{key}: #{value}" to an output buffer.

[Source]

    # File lib/mongrel/header_out.rb, line 21
21:     def[]=(key,value)
22:       if not @sent.has_key?(key) or @allowed_duplicates.has_key?(key)
23:         @sent[key] = true
24:         @out.write(Const::HEADER_FORMAT % [key, value])
25:       end
26:     end

[Validate]