Class: Mongrel::HeaderOut

Inherits:
Object
  • Object
show all
Defined in:
lib/mongrel.rb

Overview

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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(out) ⇒ HeaderOut

Returns a new instance of HeaderOut.



171
172
173
# File 'lib/mongrel.rb', line 171

def initialize(out)
  @out = out
end

Instance Attribute Details

#outObject (readonly)

Returns the value of attribute out.



169
170
171
# File 'lib/mongrel.rb', line 169

def out
  @out
end

Instance Method Details

#[]=(key, value) ⇒ Object

Simply writes “#key: #value” to an output buffer.



176
177
178
179
180
181
# File 'lib/mongrel.rb', line 176

def[]=(key,value)
  @out.write(key)
  @out.write(": ")
  @out.write(value)
  @out.write("\r\n")
end