class Goofy::Response

Constants

LOCATION

Attributes

body[R]
headers[R]
status[RW]

Public Class Methods

new(headers = {}) click to toggle source
# File lib/goofy.rb, line 19
def initialize(headers = {})
  @status  = nil
  @headers = headers
  @body    = []
  @length  = 0
end

Public Instance Methods

[](key) click to toggle source
# File lib/goofy.rb, line 26
def [](key)
  @headers[key]
end
[]=(key, value) click to toggle source
# File lib/goofy.rb, line 30
def []=(key, value)
  @headers[key] = value
end
finish() click to toggle source
# File lib/goofy.rb, line 47
def finish
  [@status, @headers, @body]
end
redirect(path, status = 302) click to toggle source
# File lib/goofy.rb, line 42
def redirect(path, status = 302)
  @headers[LOCATION] = path
  @status  = status
end
write(str) click to toggle source
# File lib/goofy.rb, line 34
def write(str)
  s = str.to_s

  @length += s.bytesize
  @headers[Rack::CONTENT_LENGTH] = @length.to_s
  @body << s
end